summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorInaba Hiroto <inaba@st.rim.or.jp>2001-01-09 10:04:32 +0900
committerJarkko Hietaniemi <jhi@iki.fi>2001-01-09 15:05:32 +0000
commit9b877dbba0196ef7d4c6e2b0fcfc6e6f4955d526 (patch)
treefd5d6ece1cff64d01e3ac0878ac10db3e006f5a5 /toke.c
parent238af31e4e26cc72128680a0ed0480b2b2c76175 (diff)
downloadperl-9b877dbba0196ef7d4c6e2b0fcfc6e6f4955d526.tar.gz
One more patch for UTF8
Message-ID: <3A59E510.52BAB5B9@st.rim.or.jp> UTF-8 fixes for 'x' and tr///. p4raw-id: //depot/perl@8378
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/toke.c b/toke.c
index e0d6f0773d..c6ef8e9c67 100644
--- a/toke.c
+++ b/toke.c
@@ -1383,7 +1383,8 @@ S_scan_const(pTHX_ char *start)
else {
STRLEN len = 1; /* allow underscores */
uv = (UV)scan_hex(s + 1, e - s - 1, &len);
- to_be_utf8 = TRUE;
+ if (PL_hints & HINT_UTF8)
+ to_be_utf8 = TRUE;
}
s = e + 1;
}
@@ -1425,8 +1426,6 @@ S_scan_const(pTHX_ char *start)
if (hicount) {
char *old_pvx = SvPVX(sv);
char *src, *dst;
- U8 tmpbuf[UTF8_MAXLEN+1];
- U8 *tmpend;
d = SvGROW(sv,
SvCUR(sv) + hicount + 1) +
@@ -1438,10 +1437,8 @@ S_scan_const(pTHX_ char *start)
while (src < dst) {
if (UTF8_IS_CONTINUED(*src)) {
- tmpend = uv_to_utf8(tmpbuf, (U8)*src--);
- dst -= tmpend - tmpbuf;
- Copy((char *)tmpbuf, dst+1,
- tmpend - tmpbuf, char);
+ *dst-- = UTF8_EIGHT_BIT_LO(*src);
+ *dst-- = UTF8_EIGHT_BIT_HI(*src--);
}
else {
*dst-- = *src--;
@@ -1450,7 +1447,7 @@ S_scan_const(pTHX_ char *start)
}
}
- if (to_be_utf8 || (has_utf8 && uv > 127) || uv > 255) {
+ if (to_be_utf8 || has_utf8 || uv > 255) {
d = (char*)uv_to_utf8((U8*)d, uv);
has_utf8 = TRUE;
}