From: Yves Orton Date: Mon, 12 Feb 2007 19:15:33 +0000 (+0100) Subject: Re: [perl #41492] Incorrect match with /(?(DEFINE)(? (?&B)+)(? a))/ X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3e901dc0c5f53f3c2d9be0ef298df8eecfbaa8bd;p=p5sagit%2Fp5-mst-13.2.git Re: [perl #41492] Incorrect match with /(?(DEFINE)(? (?&B)+)(? a))/ Message-ID: <9b18b3110702121015o1c84ff6hfd69cfa645fae0bf@mail.gmail.com> p4raw-id: //depot/perl@30236 --- diff --git a/regexec.c b/regexec.c index 72b9e87..daa8e00 100644 --- a/regexec.c +++ b/regexec.c @@ -122,8 +122,11 @@ /* 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; } diff --git a/t/op/re_tests b/t/op/re_tests index aa6ec7b..6a590b1 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -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)(?(?&B)+)(?a))(?&A) a y $& a +(?(DEFINE)(?(?&B)+)(?a))(?&A) aa y $& aa