This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [perl #41492] Incorrect match with /(?(DEFINE)(?<A> (?&B)+)(?<B> a))/
authorYves Orton <demerphq@gmail.com>
Mon, 12 Feb 2007 19:15:33 +0000 (20:15 +0100)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Mon, 12 Feb 2007 18:33:45 +0000 (18:33 +0000)
Message-ID: <9b18b3110702121015o1c84ff6hfd69cfa645fae0bf@mail.gmail.com>

p4raw-id: //depot/perl@30236

regexec.c
t/op/re_tests

index 72b9e87..daa8e00 100644 (file)
--- a/regexec.c
+++ b/regexec.c
 /* TODO: Combine JUMPABLE and HAS_TEXT to cache OP(rn) */
 
 /* for use after a quantifier and before an EXACT-like node -- japhy */
-#define JUMPABLE(rn) ( \
-    OP(rn) == OPEN || OP(rn) == CLOSE || OP(rn) == EVAL || \
+/* it would be nice to rework regcomp.sym to generate this stuff. sigh */
+#define JUMPABLE(rn) (      \
+    OP(rn) == OPEN ||       \
+    (OP(rn) == CLOSE && (!cur_eval || cur_eval->u.eval.close_paren != ARG(rn))) || \
+    OP(rn) == EVAL ||   \
     OP(rn) == SUSPEND || OP(rn) == IFMATCH || \
     OP(rn) == PLUS || OP(rn) == MINMOD || \
     OP(rn) == KEEPS || (PL_regkind[OP(rn)] == VERB) || \
@@ -4394,6 +4397,12 @@ NULL
                    && UCHARAT(PL_reginput) != ST.c2)
            {
                /* simulate B failing */
+               DEBUG_OPTIMISE_r(
+                   PerlIO_printf(Perl_debug_log,
+                       "%*s  CURLYM Fast bail c1=%"IVdf" c2=%"IVdf"\n",
+                       (int)(REPORT_CODE_OFF+(depth*2)),"",
+                       (IV)ST.c1,(IV)ST.c2
+               ));
                state_num = CURLYM_B_fail;
                goto reenter_switch;
            }
index aa6ec7b..6a590b1 100644 (file)
@@ -1280,3 +1280,6 @@ X(\w+)(?=\s)|X(\w+)       Xab     y       [$1-$2] [-ab]
 (?|(?|(a)|(b))|(?|(c)|(d)))    c       y       $1      c
 (?|(?|(a)|(b))|(?|(c)|(d)))    d       y       $1      d
 (.)(?|(.)(.)x|(.)d)(.) abcde   y       $1-$2-$3-$4-$5- b-c--e--
+#Bug #41492
+(?(DEFINE)(?<A>(?&B)+)(?<B>a))(?&A)    a       y       $&      a
+(?(DEFINE)(?<A>(?&B)+)(?<B>a))(?&A)    aa      y       $&      aa