Rationalise RX_MATCH_UTF8_set()
authorDavid Mitchell <davem@iabyn.com>
Mon, 20 May 2013 16:04:44 +0000 (17:04 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 2 Jun 2013 21:28:52 +0000 (22:28 +0100)
Now that the RXf_MATCH_UTF8 flag on a regex is just used to indicate
whether the captures on a successful match are utf8, only set
this flag at the end of a successful match, rather than at the start of
the match.

This should make no functional difference the way things stand at the
moment, but makes things conceptually cleaner.

regexec.c

index bcf2b80..4aa6de0 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -639,7 +639,6 @@ Perl_re_intuit_start(pTHX_
     PERL_UNUSED_ARG(flags);
     PERL_UNUSED_ARG(data);
 
-    RX_MATCH_UTF8_set(rx,utf8_target);
     reginfo->is_utf8_target = cBOOL(utf8_target);
 
     /* CHR_DIST() would be more correct here but it makes things slow. */
@@ -2096,8 +2095,6 @@ Perl_regexec_flags(pTHX_ REGEXP * const rx, char *stringarg, char *strend,
     reginfo->intuit = 0;
     reginfo->is_utf8_target = cBOOL(utf8_target);
 
-    RX_MATCH_UTF8_set(rx, utf8_target);
-
     DEBUG_EXECUTE_r( 
         debug_start_match(rx, utf8_target, startpos, strend,
         "Matching");
@@ -2612,6 +2609,8 @@ got_it:
     if (RXp_PAREN_NAMES(prog)) 
         (void)hv_iterinit(RXp_PAREN_NAMES(prog));
 
+    RX_MATCH_UTF8_set(rx, utf8_target);
+
     /* make sure $`, $&, $', and $digit will work later */
     if ( !(flags & REXEC_NOT_FIRST) ) {
        if (flags & REXEC_COPY_STR) {