[perl #116148] Pattern utf8ness sticks around
authorDavid Mitchell <davem@iabyn.com>
Tue, 25 Dec 2012 15:39:25 +0000 (15:39 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 25 Dec 2012 15:42:59 +0000 (15:42 +0000)
Perl_re_intuit_start would set, but never unset, the RF_utf8 flag in
PL_reg_flags. This meant that two successive patterns, the first utf8 and
the sdeconfd not, that are processed using only intuit, will get the flag
wrong on the second one. The fix is trivial.

regexec.c
t/re/pat.t

index b1b57c8..03204cd 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -622,9 +622,11 @@ Perl_re_intuit_start(pTHX_ REGEXP * const rx, SV *sv, char *strpos,
 
     RX_MATCH_UTF8_set(rx,utf8_target);
 
-    if (RX_UTF8(rx)) {
+    if (RX_UTF8(rx))
        PL_reg_flags |= RF_utf8;
-    }
+    else
+       PL_reg_flags &= ~RF_utf8;
+
     DEBUG_EXECUTE_r( 
         debug_start_match(rx, utf8_target, strpos, strend,
             sv ? "Guessing start of match in sv for"
index 619b2ea..768119f 100644 (file)
@@ -19,7 +19,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 465;  # Update this when adding/deleting tests.
+plan tests => 466;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1299,6 +1299,21 @@ EOP
         }
     }
 
+    {
+       # #116148: Pattern utf8ness sticks around globally
+       # the utf8 in the first match was sticking around for the second
+       # match
+
+       use feature 'unicode_strings';
+
+       my $x = "\x{263a}";
+       $x =~ /$x/;
+
+       my $text = "Perl";
+       ok("Perl" =~ /P.*$/i, '#116148');
+    }
+
+
 } # End of sub run_tests
 
 1;