summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-09-22 17:54:12 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-09-22 18:50:50 -0700
commit5255171e6cd0accee6f76ea2980e32b3b5b8e171 (patch)
treef198188a949f401983d4493ed514365d2c09213c /pp.c
parentd8e299374017857bcc055c31b6d4a808fb862100 (diff)
downloadperl-5255171e6cd0accee6f76ea2980e32b3b5b8e171.tar.gz
[perl #94490] const fold should not trigger special split " "
The easiest way to fix this was to move the special handling out of the regexp engine. Now a flag is set on the split op itself for this case. A real regexp is still created, as that is the most convenient way to propagate locale settings, and it prevents the need to rework pp_split to handle a null regexp. This also means that custom regexp plugins no longer need to handle split specially (which they all do currently).
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/pp.c b/pp.c
index f99c460a8d..b57ee8492d 100644
--- a/pp.c
+++ b/pp.c
@@ -5299,6 +5299,7 @@ PP(pp_split)
STRLEN len;
const char *s = SvPV_const(sv, len);
const bool do_utf8 = DO_UTF8(sv);
+ const bool skipwhite = PL_op->op_flags & OPf_SPECIAL;
const char *strend = s + len;
PMOP *pm;
REGEXP *rx;
@@ -5329,7 +5330,7 @@ PP(pp_split)
rx = PM_GETRE(pm);
TAINT_IF(get_regex_charset(RX_EXTFLAGS(rx)) == REGEX_LOCALE_CHARSET &&
- (RX_EXTFLAGS(rx) & (RXf_WHITE | RXf_SKIPWHITE)));
+ (RX_EXTFLAGS(rx) & RXf_WHITE || skipwhite));
RX_MATCH_UTF8_set(rx, do_utf8);
@@ -5369,7 +5370,7 @@ PP(pp_split)
}
base = SP - PL_stack_base;
orig = s;
- if (RX_EXTFLAGS(rx) & RXf_SKIPWHITE) {
+ if (skipwhite) {
if (do_utf8) {
while (*s == ' ' || is_utf8_space((U8*)s))
s += UTF8SKIP(s);
@@ -5391,7 +5392,7 @@ PP(pp_split)
if (!limit)
limit = maxiters + 2;
- if (RX_EXTFLAGS(rx) & RXf_WHITE) {
+ if (RX_EXTFLAGS(rx) & RXf_WHITE || skipwhite) {
while (--limit) {
m = s;
/* this one uses 'm' and is a negative test */