From: Jarkko Hietaniemi Date: Wed, 28 Oct 1998 08:25:09 +0000 (+0000) Subject: Bring in #2102. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7205e44d3d0f3600c6e6dd74269cae8d4350c695;p=p5sagit%2Fp5-mst-13.2.git Bring in #2102. p4raw-id: //depot/cfgperl@2104 --- diff --git a/pp.c b/pp.c index 6a93287..9cd1c55 100644 --- a/pp.c +++ b/pp.c @@ -2444,11 +2444,31 @@ PP(pp_quotemeta) (void)SvUPGRADE(TARG, SVt_PV); SvGROW(TARG, (len * 2) + 1); d = SvPVX(TARG); - while (len--) { - if (!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)); (void)SvPOK_only(TARG);