summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-02-20 11:27:03 -0700
committerKarl Williamson <public@khwilliamson.com>2012-02-28 17:41:14 -0700
commit96f54887615ec13b0713f735c3ec6618468ec51f (patch)
treee3131b3f219a15d8e94f601c12d45ef079f1ae00
parentb4069bca6054692e4fffa8e9e04572511e910fbd (diff)
downloadperl-96f54887615ec13b0713f735c3ec6618468ec51f.tar.gz
(?foo:...) loses passed in charset
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.
-rw-r--r--regcomp.c9
-rw-r--r--t/re/pat.t11
2 files changed, 16 insertions, 4 deletions
diff --git a/regcomp.c b/regcomp.c
index 1e1dcfd3a6..1d077e3ee4 100644
--- 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) */
diff --git a/t/re/pat.t b/t/re/pat.t
index b4b7ac477f..184f1f45f7 100644
--- a/t/re/pat.t
+++ b/t/re/pat.t
@@ -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;