Revision: 334
http://vcs.pcre.org/viewvc?view=rev&revision=334
Author: ph10
Date: 2008-04-11 16:48:14 +0100 (Fri, 11 Apr 2008)
Log Message:
-----------
Fix bug in Oniguruma \g support.
Modified Paths:
--------------
code/trunk/pcre_compile.c
code/trunk/testdata/testinput2
code/trunk/testdata/testoutput2
Modified: code/trunk/pcre_compile.c
===================================================================
--- code/trunk/pcre_compile.c 2008-04-10 19:55:57 UTC (rev 333)
+++ code/trunk/pcre_compile.c 2008-04-11 15:48:14 UTC (rev 334)
@@ -1882,7 +1882,7 @@
/* 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 @@
/* 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 @@
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 @@
-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
Modified: code/trunk/testdata/testinput2
===================================================================
--- code/trunk/testdata/testinput2 2008-04-10 19:55:57 UTC (rev 333)
+++ code/trunk/testdata/testinput2 2008-04-11 15:48:14 UTC (rev 334)
@@ -2643,4 +2643,10 @@
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 /
Modified: code/trunk/testdata/testoutput2
===================================================================
--- code/trunk/testdata/testoutput2 2008-04-10 19:55:57 UTC (rev 333)
+++ code/trunk/testdata/testoutput2 2008-04-11 15:48:14 UTC (rev 334)
@@ -9505,4 +9505,14 @@
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 /