fix build under -DPERL_NO_COW
authorDavid Mitchell <davem@iabyn.com>
Fri, 19 Jul 2013 19:07:56 +0000 (20:07 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 28 Jul 2013 09:33:39 +0000 (10:33 +0100)
An earlier commit in this branch fixed up capturing on intuit-only
matches.
However, the new code grabbed the buffer before setting offs[0].start,
offs[0].end.  Under old-style non-COW, it uses offs[0].start and end to
determine what subset to the buffer to capture. So set them first!

regexec.c

index 5189aec..4d317cf 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2310,15 +2310,15 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
              * Let @-, @+, $^N know */
             prog->lastparen = prog->lastcloseparen = 0;
             RX_MATCH_UTF8_set(rx, utf8_target);
+            prog->offs[0].start = s - strbeg;
+            prog->offs[0].end = utf8_target
+                ? (char*)utf8_hop((U8*)s, prog->minlenret) - strbeg
+                : s - strbeg + prog->minlenret;
             if ( !(flags & REXEC_NOT_FIRST) )
                 S_reg_set_capture_string(aTHX_ rx,
                                         strbeg, strend,
                                         sv, flags, utf8_target);
 
-            prog->offs[0].start = s - strbeg;
-            prog->offs[0].end = utf8_target
-                ? (char*)utf8_hop((U8*)s, prog->minlenret) - strbeg
-                : s - strbeg + prog->minlenret;
            return 1;
         }
     }