diff options
author | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2008-04-11 15:48:14 +0000 |
---|---|---|
committer | ph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15> | 2008-04-11 15:48:14 +0000 |
commit | f5fb7cc67b4338d6eadac91effd3ff4f30c33dde (patch) | |
tree | f610daedef22e1532639cdce173f57635191e9f6 | |
parent | abbf313ccbce42c4e297c87550813203ec3cf81e (diff) | |
download | pcre-f5fb7cc67b4338d6eadac91effd3ff4f30c33dde.tar.gz |
Fix bug in Oniguruma \g support.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@334 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r-- | pcre_compile.c | 9 | ||||
-rw-r--r-- | testdata/testinput2 | 6 | ||||
-rw-r--r-- | testdata/testoutput2 | 10 |
3 files changed, 21 insertions, 4 deletions
diff --git a/pcre_compile.c b/pcre_compile.c index aed8190..f7be568 100644 --- a/pcre_compile.c +++ b/pcre_compile.c @@ -1882,7 +1882,7 @@ while ((ptr = (uschar *)find_recurse(ptr, utf8)) != NULL) /* See if this recursion is on the forward reference list. If so, adjust the reference. */ - + for (hc = save_hwm; hc < cd->hwm; hc += LINK_SIZE) { offset = GET(hc, 0); @@ -2458,7 +2458,7 @@ for (;; ptr++) /* Get next byte in the pattern */ c = *ptr; - + /* If we are in the pre-compile phase, accumulate the length used for the previous cycle of this loop. */ @@ -4138,7 +4138,7 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */ bravalue = OP_CBRA; save_hwm = cd->hwm; reset_bracount = FALSE; - + /* First deal with various "verbs" that can be introduced by '*'. */ if (*(++ptr) == '*' && (cd->ctypes[ptr[1]] & ctype_letter) != 0) @@ -5127,11 +5127,12 @@ we set the flag only if there is a literal "\r" or "\n" in the class. */ -ESC_g is returned only for these cases. So we don't need to check for < or ' if the value is -ESC_g. For the Perl syntax \g{n} the value is -ESC_REF+n, and for the Perl syntax \g{name} the result is -ESC_k (as - that is a synonym). */ + that is a synonym for a named back reference). */ if (-c == ESC_g) { const uschar *p; + save_hwm = cd->hwm; /* Normally this is set when '(' is read */ terminator = (*(++ptr) == '<')? '>' : '\''; /* These two statements stop the compiler for warning about possibly diff --git a/testdata/testinput2 b/testdata/testinput2 index 4ef241d..a4a0326 100644 --- a/testdata/testinput2 +++ b/testdata/testinput2 @@ -2643,4 +2643,10 @@ a random value. /Ix XaaX XAAX +/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/ + +/(?<n>a|b|c)\g<n>*/ + abc + accccbbb + / End of testinput2 / diff --git a/testdata/testoutput2 b/testdata/testoutput2 index ae25cfa..c2e41f7 100644 --- a/testdata/testoutput2 +++ b/testdata/testoutput2 @@ -9505,4 +9505,14 @@ No match 0: AA 1: A +/(?=(?<regex>(?#simplesyntax)\$(?<name>[a-zA-Z_\x{7f}-\x{ff}][a-zA-Z0-9_\x{7f}-\x{ff}]*)(?:\[(?<index>[a-zA-Z0-9_\x{7f}-\x{ff}]+|\$\g<name>)\]|->\g<name>(\(.*?\))?)?|(?#simple syntax withbraces)\$\{(?:\g<name>(?<indices>\[(?:\g<index>|'(?:\\.|[^'\\])*'|"(?:\g<regex>|\\.|[^"\\])*")\])?|\g<complex>|\$\{\g<complex>\})\}|(?#complexsyntax)\{(?<complex>\$(?<segment>\g<name>(\g<indices>*|\(.*?\))?)(?:->\g<segment>)*|\$\g<complex>|\$\{\g<complex>\})\}))\{/ + +/(?<n>a|b|c)\g<n>*/ + abc + 0: abc + 1: a + accccbbb + 0: accccbbb + 1: a + / End of testinput2 / |