summaryrefslogtreecommitdiff
path: root/doop.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-01-05 00:47:23 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-05 00:47:23 +0000
commita0dbb04553005cdbafdeb7435a79ae500b5aa8ff (patch)
treec3c2af7757f55ba66089c19094e138ecb04cb469 /doop.c
parent7a800fca3140c85b8a41515633e9bb98c38e5603 (diff)
downloadperl-a0dbb04553005cdbafdeb7435a79ae500b5aa8ff.tar.gz
Unify UTF-8 malformedness handling.
p4raw-id: //depot/perl@8323
Diffstat (limited to 'doop.c')
-rw-r--r--doop.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/doop.c b/doop.c
index 868be2266b..f6dbe67a6b 100644
--- a/doop.c
+++ b/doop.c
@@ -833,15 +833,15 @@ Perl_do_chop(pTHX_ register SV *astr, register SV *sv)
char *send = s + len;
char *start = s;
s = send - 1;
- while ((*s & 0xc0) == 0x80)
- --s;
- if (UTF8SKIP(s) != send - s && ckWARN_d(WARN_UTF8))
- Perl_warner(aTHX_ WARN_UTF8, "Malformed UTF-8 character");
- sv_setpvn(astr, s, send - s);
- *s = '\0';
- SvCUR_set(sv, s - start);
- SvNIOK_off(sv);
- SvUTF8_on(astr);
+ while (s > start && UTF8_IS_CONTINUATION(*s))
+ s--;
+ if (utf8_to_uv_simple((U8*)s, 0)) {
+ sv_setpvn(astr, s, send - s);
+ *s = '\0';
+ SvCUR_set(sv, s - start);
+ SvNIOK_off(sv);
+ SvUTF8_on(astr);
+ }
}
else
sv_setpvn(astr, "", 0);