regexec_flags(): use result of intuit_start()
authorDavid Mitchell <davem@iabyn.com>
Wed, 10 Jul 2013 12:35:51 +0000 (13:35 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 28 Jul 2013 09:33:37 +0000 (10:33 +0100)
When I moved the call to re_intuit_start() into Perl_regexec_flags()
a few commits earlier, I assigned the return value to the wrong variable,
so a subsequent match would still start at the beginning, not at the
intuited start point. This commit corrects that, by updating startpos
rather than stringarg.

regexec.c

index b05b152..6aacd0b 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2278,9 +2278,9 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
     if ((RX_EXTFLAGS(rx) & RXf_USE_INTUIT)
         && !(flags & REXEC_CHECKED))
     {
-       stringarg = re_intuit_start(rx, sv, strbeg, stringarg, strend,
+       startpos = re_intuit_start(rx, sv, strbeg, stringarg, strend,
                                     flags, NULL);
-       if (!stringarg)
+       if (!startpos)
            return 0;
 
        if (RX_EXTFLAGS(rx) & RXf_CHECK_ALL) {
@@ -2297,10 +2297,10 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
                                         strbeg, strend,
                                         sv, flags, utf8_target);
 
-            prog->offs[0].start = stringarg - strbeg;
+            prog->offs[0].start = startpos - strbeg;
             prog->offs[0].end = utf8_target
-                ? (char*)utf8_hop((U8*)stringarg, prog->minlenret) - strbeg
-                : stringarg - strbeg + prog->minlenret;
+                ? (char*)utf8_hop((U8*)startpos, prog->minlenret) - strbeg
+                : startpos - strbeg + prog->minlenret;
            return 1;
         }
     }
@@ -2338,7 +2338,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
     reginfo->poscache_maxiter = 0; /* not yet started a countdown */
     reginfo->strend = strend;
     /* see how far we have to get to not match where we matched before */
-    reginfo->till = startpos+minend;
+    reginfo->till = stringarg + minend;
 
     if (prog->extflags & RXf_EVAL_SEEN && SvPADTMP(sv) && !IS_PADGV(sv)) {
         /* SAVEFREESV, not sv_mortalcopy, as this SV must last until after