From: Hugo van der Sanden Date: Thu, 10 Aug 2000 19:23:04 +0000 (+0100) Subject: Re: [ID 20000809.005] trouble with long string and /m modifier - uninitialized value X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e39e1e56bf08c329cf6e45b28d658ce846c1e16;p=p5sagit%2Fp5-mst-13.2.git Re: [ID 20000809.005] trouble with long string and /m modifier - uninitialized value Message-Id: <200008101823.TAA23580@crypt.compulink.co.uk> p4raw-id: //depot/perl@6591 --- diff --git a/regexec.c b/regexec.c index 002b66a..cbc8c19 100644 --- 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 */ diff --git a/t/op/pat.t b/t/op/pat.t index 76a7ef3..fbc234b 100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -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++;