This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [ID 20000809.005] trouble with long string and /m modifier - uninitialized value
authorHugo van der Sanden <hv@crypt.org>
Thu, 10 Aug 2000 19:23:04 +0000 (20:23 +0100)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 11 Aug 2000 01:22:02 +0000 (01:22 +0000)
Message-Id: <200008101823.TAA23580@crypt.compulink.co.uk>

p4raw-id: //depot/perl@6591

regexec.c
t/op/pat.t

index 002b66a..cbc8c19 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -690,6 +690,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
            SvREFCNT_dec(prog->check_substr);
            prog->check_substr = Nullsv;        /* disable */
            prog->float_substr = Nullsv;        /* clear */
+           check = Nullsv;                     /* abort */
            s = strpos;
            /* XXXX This is a remnant of the old implementation.  It
                    looks wasteful, since now INTUIT can use many
@@ -752,6 +753,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                                               "Could not match STCLASS...\n") );
                        goto fail;
                    }
+                   if (!check)
+                       goto giveup;
                    DEBUG_r( PerlIO_printf(Perl_debug_log,
                                "Looking for %s substr starting at offset %ld...\n",
                                 what, (long)(s + start_shift - i_strpos)) );
@@ -762,6 +765,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                    goto retry_floating_check;
                /* Recheck anchored substring, but not floating... */
                s = check_at; 
+               if (!check)
+                   goto giveup;
                DEBUG_r( PerlIO_printf(Perl_debug_log,
                          "Looking for anchored substr starting at offset %ld...\n",
                          (long)(other_last - i_strpos)) );
@@ -771,6 +776,8 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                current position only: */
            if (ml_anch) {
                s = t = t + 1;
+               if (!check)
+                   goto giveup;
                DEBUG_r( PerlIO_printf(Perl_debug_log,
                          "Looking for /%s^%s/m starting at offset %ld...\n",
                          PL_colors[0],PL_colors[1], (long)(t - i_strpos)) );
@@ -792,8 +799,10 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
                     PerlIO_printf(Perl_debug_log, 
                        "Does not contradict STCLASS...\n") );
     }
-    DEBUG_r(PerlIO_printf(Perl_debug_log, "%sGuessed:%s match at offset %ld\n",
-                         PL_colors[4], PL_colors[5], (long)(s - i_strpos)) );
+  giveup:
+    DEBUG_r(PerlIO_printf(Perl_debug_log, "%s%s:%s match at offset %ld\n",
+                         PL_colors[4], (check ? "Guessed" : "Giving up"),
+                         PL_colors[5], (long)(s - i_strpos)) );
     return s;
 
   fail_finish:                         /* Substring not found */
index 76a7ef3..fbc234b 100755 (executable)
@@ -4,7 +4,7 @@
 # the format supported by op/regexp.t.  If you want to add a test
 # that does fit that format, add it to op/re_tests, not here.
 
-print "1..215\n";
+print "1..216\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -1025,3 +1025,12 @@ $test++;
 'a1b' =~ ('xyz' =~ /t/) and $` eq 'a' or print "not ";
 print "ok $test\n";
 $test++;
+
+$w = 0;
+{
+    local $SIG{__WARN__} = sub { $w = 1 };
+    local $^W = 1;
+       $w = 1 if ("1\n" x 102) =~ /^\s*\n/m;
+}
+print $w ? "not " : "", "ok $test\n";
+$test++;