Skip to content

Commit 96f5488

Browse files
author
Karl Williamson
committed
(?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.
1 parent b4069bc commit 96f5488

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

regcomp.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8010,9 +8010,12 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
80108010
U32 posflags = 0, negflags = 0;
80118011
U32 *flagsp = &posflags;
80128012
char has_charset_modifier = '\0';
8013-
regex_charset cs = (RExC_utf8 || RExC_uni_semantics)
8014-
? REGEX_UNICODE_CHARSET
8015-
: REGEX_DEPENDS_CHARSET;
8013+
regex_charset cs = get_regex_charset(RExC_flags);
8014+
if (cs == REGEX_DEPENDS_CHARSET
8015+
&& (RExC_utf8 || RExC_uni_semantics))
8016+
{
8017+
cs = REGEX_UNICODE_CHARSET;
8018+
}
80168019

80178020
while (*RExC_parse) {
80188021
/* && strchr("iogcmsx", *RExC_parse) */

t/re/pat.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BEGIN {
2121
require './test.pl';
2222
}
2323

24-
plan tests => 469; # Update this when adding/deleting tests.
24+
plan tests => 472; # Update this when adding/deleting tests.
2525

2626
run_tests() unless caller;
2727

@@ -1253,6 +1253,15 @@ EOP
12531253
$anch_count++ while $str=~/^.*/mg;
12541254
is $anch_count, 1, 'while "\n"=~/^.*/mg should match only once';
12551255
}
1256+
1257+
{ # [perl #111174]
1258+
use re '/u';
1259+
like "\xe0", qr/(?i:\xc0)/, "(?i: shouldn't lose the passed in /u";
1260+
use re '/a';
1261+
unlike "\x{100}", qr/(?i:\w)/, "(?i: shouldn't lose the passed in /a";
1262+
use re '/aa';
1263+
unlike 'k', qr/(?i:\N{KELVIN SIGN})/, "(?i: shouldn't lose the passed in /aa";
1264+
}
12561265
} # End of sub run_tests
12571266

12581267
1;

0 commit comments

Comments
 (0)