From: Larry Wall Date: Tue, 27 Oct 1998 18:58:55 +0000 (+0000) Subject: utf8 change to quotemeta broke EBCDIC X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0dd2cdef082b8bc24e64c02fcb29904168be24b5;p=p5sagit%2Fp5-mst-13.2.git utf8 change to quotemeta broke EBCDIC p4raw-id: //depot/perl@2102 --- diff --git a/pp.c b/pp.c index 05b242a..63f20b8 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));