Revert "'use utf8' should imply /u regex matching"
authorKarl Williamson <public@khwilliamson.com>
Tue, 4 Feb 2014 17:43:42 +0000 (10:43 -0700)
committerKarl Williamson <public@khwilliamson.com>
Tue, 4 Feb 2014 17:56:50 +0000 (10:56 -0700)
This reverts commit bfa0ee78b652802412c3cab86bb873ed67ea6550.

This commit turned out to be contentious, and since we are past the
contentious features freeze date, no matter what else, it should be
reverted.

The argument for the commit essentially boils down to 'use utf8'
indicates that the text within its scope should be treated as utf8.
That means that any patterns with literals in them should be treated as
utf8, but utf8-encoded patterns follow Unicode rules by definition.

The arguments against it are that code relies on the way it has always
worked (even if that was an oversight), and in fact several CPAN modules
were broken by it, [perl #121162].  Also it has been the stated intent
that 'use utf8' will eventually become a no-op, meaning all text will be
treated as utf8, and that shouldn't have to mean that backwards
compatibility will be broken then.

regcomp.c
t/re/pat.t

index ba63f1f..fa8a61a 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -6305,10 +6305,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
 
     /* ignore the utf8ness if the pattern is 0 length */
     RExC_utf8 = RExC_orig_utf8 = (plen == 0 || IN_BYTES) ? 0 : SvUTF8(pat);
-
-    /* 'use utf8' in the program indicates Unicode rules are wanted */
-    RExC_uni_semantics = (PL_hints & HINT_UTF8);
-
+    RExC_uni_semantics = 0;
     RExC_contains_locale = 0;
     RExC_contains_i = 0;
     pRExC_state->runtime_code_qr = NULL;
@@ -6359,13 +6356,10 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
     if (initial_charset == REGEX_LOCALE_CHARSET) {
        RExC_contains_locale = 1;
     }
-    else if ((RExC_utf8 || RExC_uni_semantics)
-              && initial_charset == REGEX_DEPENDS_CHARSET)
-    {
+    else if (RExC_utf8 && initial_charset == REGEX_DEPENDS_CHARSET) {
 
-        /* Set to use unicode semantics if has the 'depends' charset specified,
-         * and either the pattern is in utf8 (as it means unicode when utf8),
-         * or we already know we want unicode rules  */
+       /* Set to use unicode semantics if the pattern is in utf8 and has the
+        * 'depends' charset specified, as it means unicode when utf8  */
        set_regex_charset(&rx_flags, REGEX_UNICODE_CHARSET);
     }
 
index 6211065..91274e6 100644 (file)
@@ -20,7 +20,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 713;  # Update this when adding/deleting tests.
+plan tests => 712;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1538,10 +1538,6 @@ EOP
         like "\x{AA}", qr/a?[\W_]/d, "\\W with /d synthetic start class works";
     }
 
-    {
-        use utf8;
-        unlike("\xe0", qr/\W/, "'use utf8' implies /u");
-    }
 
 
 } # End of sub run_tests