summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorLarry Wall <larry@wall.org>1998-10-27 18:58:55 +0000
committerLarry Wall <larry@wall.org>1998-10-27 18:58:55 +0000
commit0dd2cdef082b8bc24e64c02fcb29904168be24b5 (patch)
treebe7af39999bd152132bc1d76c843c2f104e85b70 /pp.c
parentb86a2fa703d0daf651095b1947eb50e3b5cc41d9 (diff)
downloadperl-0dd2cdef082b8bc24e64c02fcb29904168be24b5.tar.gz
utf8 change to quotemeta broke EBCDIC
p4raw-id: //depot/perl@2102
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/pp.c b/pp.c
index 05b242a619..63f20b8a0a 100644
--- a/pp.c
+++ b/pp.c
@@ -2444,10 +2444,30 @@ PP(pp_quotemeta)
(void)SvUPGRADE(TARG, SVt_PV);
SvGROW(TARG, (len * 2) + 1);
d = SvPVX(TARG);
- while (len--) {
- if (!(*s & 0x80) && !isALNUM(*s))
- *d++ = '\\';
- *d++ = *s++;
+ if (IN_UTF8) {
+ while (len) {
+ if (*s & 0x80) {
+ STRLEN ulen = UTF8SKIP(s);
+ if (ulen > len)
+ ulen = len;
+ len -= ulen;
+ while (ulen--)
+ *d++ = *s++;
+ }
+ else {
+ if (!isALNUM(*s))
+ *d++ = '\\';
+ *d++ = *s++;
+ len--;
+ }
+ }
+ }
+ else {
+ while (len--) {
+ if (!isALNUM(*s))
+ *d++ = '\\';
+ *d++ = *s++;
+ }
}
*d = '\0';
SvCUR_set(TARG, d - SvPVX(TARG));