This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
(?foo:...) loses passed in charset
authorKarl Williamson <public@khwilliamson.com>
Mon, 20 Feb 2012 18:27:03 +0000 (11:27 -0700)
committerKarl Williamson <public@khwilliamson.com>
Wed, 29 Feb 2012 00:41:14 +0000 (17:41 -0700)
This commit looks for the passed-in charset, and overrides it only if it
is /d and the pattern requires /u.  Previously the passed-in value was
ignored.

regcomp.c
t/re/pat.t

index 1e1dcfd..1d077e3 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -8010,9 +8010,12 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
                 U32 posflags = 0, negflags = 0;
                U32 *flagsp = &posflags;
                 char has_charset_modifier = '\0';
-               regex_charset cs = (RExC_utf8 || RExC_uni_semantics)
-                                   ? REGEX_UNICODE_CHARSET
-                                   : REGEX_DEPENDS_CHARSET;
+               regex_charset cs = get_regex_charset(RExC_flags);
+               if (cs == REGEX_DEPENDS_CHARSET
+                   && (RExC_utf8 || RExC_uni_semantics))
+               {
+                   cs = REGEX_UNICODE_CHARSET;
+               }
 
                while (*RExC_parse) {
                    /* && strchr("iogcmsx", *RExC_parse) */
index b4b7ac4..184f1f4 100644 (file)
@@ -21,7 +21,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan tests => 469;  # Update this when adding/deleting tests.
+plan tests => 472;  # Update this when adding/deleting tests.
 
 run_tests() unless caller;
 
@@ -1253,6 +1253,15 @@ EOP
         $anch_count++ while $str=~/^.*/mg;
         is $anch_count, 1, 'while "\n"=~/^.*/mg should match only once';
     }
+
+    { # [perl #111174]
+        use re '/u';
+        like "\xe0", qr/(?i:\xc0)/, "(?i: shouldn't lose the passed in /u";
+        use re '/a';
+        unlike "\x{100}", qr/(?i:\w)/, "(?i: shouldn't lose the passed in /a";
+        use re '/aa';
+        unlike 'k', qr/(?i:\N{KELVIN SIGN})/, "(?i: shouldn't lose the passed in /aa";
+    }
 } # End of sub run_tests
 
 1;