summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/pp.c b/pp.c
index 02e530f974..54df53e6a5 100644
--- a/pp.c
+++ b/pp.c
@@ -4726,26 +4726,36 @@ PP(pp_split)
else
EXTEND(SP, slen);
- while (--limit) {
- m = s;
-
- if (do_utf8)
+ if (do_utf8) {
+ while (--limit) {
+ /* keep track of how many bytes we skip over */
+ m = s;
s += UTF8SKIP(s);
- else
- ++s;
+ dstr = newSVpvn(m, s-m);
- dstr = newSVpvn(m, s-m);
+ if (make_mortal)
+ sv_2mortal(dstr);
- if (make_mortal)
- sv_2mortal(dstr);
- if (do_utf8)
(void)SvUTF8_on(dstr);
+ PUSHs(dstr);
- PUSHs(dstr);
+ if (s >= strend)
+ break;
+ }
+ } else {
+ while (--limit) {
+ dstr = newSVpvn(s, 1);
+
+ s++;
+
+ if (make_mortal)
+ sv_2mortal(dstr);
- /* are we there yet? */
- if (s >= strend)
- break;
+ PUSHs(dstr);
+
+ if (s >= strend)
+ break;
+ }
}
}
else if (do_utf8 == ((rx->extflags & RXf_UTF8) != 0) &&