From 3a8d9ca55d4682d6c506da08521848caf13ff318 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 7 May 2010 15:24:50 -0400 Subject: [PATCH] token matching loop storing ovector for longest match so the longest-matching token does not need to be re-matched to obtain subpattern match strings --- tmpl/parser.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tmpl/parser.cc b/tmpl/parser.cc index 15af369..f6583c9 100644 --- a/tmpl/parser.cc +++ b/tmpl/parser.cc @@ -1,4 +1,6 @@ +#include /* memcpy() */ + #include #include @@ -86,6 +88,7 @@ bool I_CLASSNAME::parse(istream & i) { int longest_match_length = 0; int longest_match_index; + int longest_match_ovector[ovector_size]; for (int i = 0; i < sizeof(tokens)/sizeof(tokens[0]); i++) { int rc = pcre_exec(tokens[i].re, tokens[i].re_extra, @@ -100,6 +103,7 @@ bool I_CLASSNAME::parse(istream & i) { longest_match_length = len; longest_match_index = i; + memcpy(longest_match_ovector, ovector, sizeof(ovector)); } } }