diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 1998-10-28 08:25:09 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 1998-10-28 08:25:09 +0000 |
commit | 7205e44d3d0f3600c6e6dd74269cae8d4350c695 (patch) | |
tree | dc9570350799ee8350a5308c974aef1462876e59 /pp.c | |
parent | b9416812b7330d57b47d469866c91cac87d6391b (diff) | |
download | perl-7205e44d3d0f3600c6e6dd74269cae8d4350c695.tar.gz |
Bring in #2102.
p4raw-id: //depot/cfgperl@2104
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 28 |
1 files changed, 24 insertions, 4 deletions
@@ -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); |