In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/688e03912e3bff2d2419c457d8b0e1bab3eb7112?hp=04f745798a0e989d3948b52426ed936a1b2dfc51>
- Log ----------------------------------------------------------------- commit 688e03912e3bff2d2419c457d8b0e1bab3eb7112 Author: Father Chrysostomos <spr...@cpan.org> Date: Sun Jun 9 18:42:47 2013 -0700 Stop /(a|b)(?=a){3}/ from warning twice [sprout@dromedary-001 perl2.git]$ ../perl.git/Porting/bisect.pl --target=miniperl --start=perl-5.8.0 --end=v5.10.0 -- ./miniperl -Ilib -we 'BEGIN { $SIG{__WARN__} = sub { die if $_[0] =~ /Quantifier/ && $warned++; warn shift }}; ""=~/(N|N)(?{})?/' ... 07be1b83a6b2d24b492356181ddf70e1c7917ae3 is the first bad commit commit 07be1b83a6b2d24b492356181ddf70e1c7917ae3 Author: Yves Orton <demer...@gmail.com> Date: Fri Jun 9 02:56:37 2006 +0200 Re: [PATCH] Better version of the Aho-Corasick patch and lots of benchmarks. Message-ID: <9b18b3110606081556t779de698r82f361d82a05f...@mail.gmail.com> (with tweaks) p4raw-id: //depot/perl@28373 Since that commit, it has been possible for S_study_chunk to be called twice if the trie optimisation kicks in (which happens for /(a|b)/). âQuantifier unexpected on zero-length expressionâ is the only warning in S_study_chunk. Now it can appear twice if the quantified zero- length expression is in the same regexp as a trie optimisation. So pass a flag to S_study_chunk when ârestudyingâ to indicate that the warning should be skipped. There are two code paths that call S_study_chunk, one for when there is no top-level alternation, which triggers the error in this case, and one for when there is a top-level alternation (/a|b/). I wasnât able to figure out how to trigger the double warning in the second case, but I passed the flag for the restudy in that code path anyway, since I donât think it can be wrong. M regcomp.c M t/re/reg_mesg.t commit 636013b3f52d8d822c7b83d79398d51b08c82838 Author: Father Chrysostomos <spr...@cpan.org> Date: Sun Jun 9 17:30:56 2013 -0700 Remove âbad top formatâ error This is unreachable. It only happens in pp_leavewrite when IoTOP_GV(io) is null, but the code leading up to it makes sure that IoTOP_GV(io) is not null. If it is still null, it jumps past the error with âgoto forget_topâ. M pp_sys.c M t/porting/diag.t ----------------------------------------------------------------------- Summary of changes: pp_sys.c | 3 +-- regcomp.c | 15 +++++++++++---- t/porting/diag.t | 1 - t/re/reg_mesg.t | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pp_sys.c b/pp_sys.c index b5efeb4..a6603ce 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1470,8 +1470,7 @@ PP(pp_leavewrite) PL_formtarget = PL_toptarget; IoFLAGS(io) |= IOf_DIDTOP; fgv = IoTOP_GV(io); - if (!fgv) - DIE(aTHX_ "bad top format reference"); + assert(fgv); /* IoTOP_GV(io) should have been set above */ cv = GvFORM(fgv); if (!cv) { SV * const sv = sv_newmortal(); diff --git a/regcomp.c b/regcomp.c index eb91465..a9eebd7 100644 --- a/regcomp.c +++ b/regcomp.c @@ -405,6 +405,7 @@ static const scan_data_t zero_scan_data = #define SCF_TRIE_RESTUDY 0x4000 /* Do restudy? */ #define SCF_SEEN_ACCEPT 0x8000 +#define SCF_TRIE_DOING_RESTUDY 0x10000 #define UTF cBOOL(RExC_utf8) @@ -3909,8 +3910,9 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, } if (!scan) /* It was not CURLYX, but CURLY. */ scan = next; - if ( /* ? quantifier ok, except for (?{ ... }) */ - (next_is_eval || !(mincount == 0 && maxcount == 1)) + if (!(flags & SCF_TRIE_DOING_RESTUDY) + /* ? quantifier ok, except for (?{ ... }) */ + && (next_is_eval || !(mincount == 0 && maxcount == 1)) && (minnext == 0) && (deltanext == 0) && data && !(data->flags & (SF_HAS_PAR|SF_IN_PAR)) && maxcount <= REG_INFTY/3) /* Complement check for big count */ @@ -6223,7 +6225,9 @@ reStudy: minlen = study_chunk(pRExC_state, &first, &minlen, &fake, scan + RExC_size, /* Up to end */ &data, -1, NULL, NULL, - SCF_DO_SUBSTR | SCF_WHILEM_VISITED_POS | stclass_flag,0); + SCF_DO_SUBSTR | SCF_WHILEM_VISITED_POS | stclass_flag + | (restudied ? SCF_TRIE_DOING_RESTUDY : 0), + 0); CHECK_RESTUDY_GOTO_butfirst(LEAVE_with_name("study_chunk")); @@ -6359,7 +6363,10 @@ reStudy: minlen = study_chunk(pRExC_state, &scan, &minlen, &fake, scan + RExC_size, - &data, -1, NULL, NULL, SCF_DO_STCLASS_AND|SCF_WHILEM_VISITED_POS,0); + &data, -1, NULL, NULL, + SCF_DO_STCLASS_AND|SCF_WHILEM_VISITED_POS + |(restudied ? SCF_TRIE_DOING_RESTUDY : 0), + 0); CHECK_RESTUDY_GOTO_butfirst(NOOP); diff --git a/t/porting/diag.t b/t/porting/diag.t index ebf9b48..51936fd 100644 --- a/t/porting/diag.t +++ b/t/porting/diag.t @@ -457,7 +457,6 @@ sub check_message { __DATA__ Malformed UTF-8 character (unexpected non-continuation byte 0x%x, immediately after start byte 0x%x) -bad top format reference Cannot apply "%s" in non-PerlIO perl Can't %s big-endian %ss on this Can't call mro_isa_changed_in() on anonymous symbol table diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t index 2a3bd8d..b8098fd 100644 --- a/t/re/reg_mesg.t +++ b/t/re/reg_mesg.t @@ -211,6 +211,7 @@ my @warning = ( '/\q/' => 'Unrecognized escape \q passed through {#} m/\q{#}/', '/\q{/' => 'Unrecognized escape \q{ passed through {#} m/\q{{#}/', '/(?=a){1,3}/' => 'Quantifier unexpected on zero-length expression {#} m/(?=a){1,3}{#}/', + '/(a|b)(?=a){3}/' => 'Quantifier unexpected on zero-length expression {#} m/(a|b)(?=a){3}{#}/', '/\_/' => "", '/[\_\0]/' => "", '/[\07]/' => "", -- Perl5 Master Repository