This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH] valgrind and /#/x
authorAdrian M. Enache <enache@rdslink.ro>
Tue, 26 Aug 2003 08:11:07 +0000 (11:11 +0300)
committerJarkko Hietaniemi <jhi@iki.fi>
Tue, 26 Aug 2003 05:18:15 +0000 (05:18 +0000)
Message-ID: <20030826051107.GA1086@ratsnest.hole>

p4raw-id: //depot/perl@20901

regcomp.c
t/op/re_tests
t/run/fresh_perl.t
toke.c

index 556922a..80e5cfb 100644 (file)
--- 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;
            }
        }
index b794aea..1bec50b 100644 (file)
@@ -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
index a0f707f..1fd4417 100644 (file)
@@ -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 (file)
--- 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++);
            }