summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2000-10-06 20:51:48 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-10-06 20:51:48 +0000
commit28cb335941d0814ffcf5fac9c747a344a59ce5dc (patch)
tree7706e4c78cfcdc6a61023fc3ece5eafd54df7bbe /pp.c
parentf130fd4589cf5fbb24149cd4db4137c8326f49c1 (diff)
downloadperl-28cb335941d0814ffcf5fac9c747a344a59ce5dc.tar.gz
UTF8ize split() so that the cloned substrings get the UTF8
flag of the original scalar. Problem reported by Simon Cozens. p4raw-id: //depot/perl@7164
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/pp.c b/pp.c
index 01cb0707fa..8877d8a469 100644
--- a/pp.c
+++ b/pp.c
@@ -4974,6 +4974,7 @@ PP(pp_split)
AV *ary;
register I32 limit = POPi; /* note, negative is forever */
SV *sv = POPs;
+ bool isutf = DO_UTF8(sv);
STRLEN len;
register char *s = SvPV(sv, len);
char *strend = s + len;
@@ -5076,6 +5077,8 @@ PP(pp_split)
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
+ if (isutf)
+ (void)SvUTF8_on(dstr);
XPUSHs(dstr);
s = m + 1;
@@ -5096,6 +5099,8 @@ PP(pp_split)
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
+ if (isutf)
+ (void)SvUTF8_on(dstr);
XPUSHs(dstr);
s = m;
}
@@ -5119,6 +5124,8 @@ PP(pp_split)
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
+ if (isutf)
+ (void)SvUTF8_on(dstr);
XPUSHs(dstr);
s = m + 1;
}
@@ -5134,6 +5141,8 @@ PP(pp_split)
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
+ if (isutf)
+ (void)SvUTF8_on(dstr);
XPUSHs(dstr);
s = m + len; /* Fake \n at the end */
}
@@ -5161,6 +5170,8 @@ PP(pp_split)
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
+ if (isutf)
+ (void)SvUTF8_on(dstr);
XPUSHs(dstr);
if (rx->nparens) {
for (i = 1; i <= rx->nparens; i++) {
@@ -5174,6 +5185,8 @@ PP(pp_split)
dstr = NEWSV(33, 0);
if (make_mortal)
sv_2mortal(dstr);
+ if (isutf)
+ (void)SvUTF8_on(dstr);
XPUSHs(dstr);
}
}
@@ -5192,6 +5205,8 @@ PP(pp_split)
sv_setpvn(dstr, s, strend-s);
if (make_mortal)
sv_2mortal(dstr);
+ if (isutf)
+ (void)SvUTF8_on(dstr);
XPUSHs(dstr);
iters++;
}