From: Adrian M. Enache Date: Tue, 26 Aug 2003 08:11:07 +0000 (+0300) Subject: Re: [PATCH] valgrind and /#/x X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e994fd663a4d8acc8c717fa28479d849341d1bb4;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH] valgrind and /#/x Message-ID: <20030826051107.GA1086@ratsnest.hole> p4raw-id: //depot/perl@20901 --- diff --git a/regcomp.c b/regcomp.c index 556922a..80e5cfb 100644 --- a/regcomp.c +++ b/regcomp.c @@ -4272,8 +4272,11 @@ S_nextchar(pTHX_ RExC_state_t *pRExC_state) for (;;) { if (*RExC_parse == '(' && RExC_parse[1] == '?' && RExC_parse[2] == '#') { - while (*RExC_parse && *RExC_parse != ')') + while (*RExC_parse != ')') { + if (RExC_parse == RExC_end) + FAIL("Sequence (?#... not terminated"); RExC_parse++; + } RExC_parse++; continue; } @@ -4283,10 +4286,8 @@ S_nextchar(pTHX_ RExC_state_t *pRExC_state) continue; } else if (*RExC_parse == '#') { - while (*RExC_parse && *RExC_parse != '\n') - RExC_parse++; - if (*RExC_parse) - RExC_parse++; + while (RExC_parse < RExC_end) + if (*RExC_parse++ == '\n') break; continue; } } diff --git a/t/op/re_tests b/t/op/re_tests index b794aea..1bec50b 100644 --- a/t/op/re_tests +++ b/t/op/re_tests @@ -941,3 +941,5 @@ a(b)?? abc y <$1> <> # undef [perl #16773] ^.{2,3}?((?:b|a|r)+?)\1\z foobarbar y $1 bar ^(?:f|o|b){2,3}?((?:b|a|r)+?)\1\z foobarbar y $1 bar .*a(?!(b|cd)*e).*f ......abef n - - # [perl #23030] +x(?# x c - Sequence (?#... not terminated +:x(?#: x c - Sequence (?#... not terminated diff --git a/t/run/fresh_perl.t b/t/run/fresh_perl.t index a0f707f..1fd4417 100644 --- a/t/run/fresh_perl.t +++ b/t/run/fresh_perl.t @@ -349,7 +349,6 @@ print "you die joe!\n" unless "@x" eq 'x y z'; ######## /(?{"{"})/ # Check it outside of eval too EXPECT -Sequence (?{...}) not terminated or not {}-balanced at - line 1, within pattern Sequence (?{...}) not terminated or not {}-balanced in regex; marked by <-- HERE in m/(?{ <-- HERE "{"})/ at - line 1. ######## /(?{"{"}})/ # Check it outside of eval too diff --git a/toke.c b/toke.c index aa20096..aef667e 100644 --- a/toke.c +++ b/toke.c @@ -1324,7 +1324,7 @@ S_scan_const(pTHX_ char *start) except for the last char, which will be done separately. */ else if (*s == '(' && PL_lex_inpat && s[1] == '?') { if (s[2] == '#') { - while (s < send && *s != ')') + while (s+1 < send && *s != ')') *d++ = NATIVE_TO_NEED(has_utf8,*s++); } else if (s[2] == '{' /* This should match regcomp.c */ @@ -1343,10 +1343,8 @@ S_scan_const(pTHX_ char *start) count--; regparse++; } - if (*regparse != ')') { + if (*regparse != ')') regparse--; /* Leave one char for continuation. */ - yyerror("Sequence (?{...}) not terminated or not {}-balanced"); - } while (s < regparse) *d++ = NATIVE_TO_NEED(has_utf8,*s++); }