summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-02-07 19:01:08 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-02-07 19:01:08 +0000
commitfefc93b9ff952105cbd75d4eccd3c8f5864a7323 (patch)
tree22fdd9e1e038d7b7b0e7be522495c7282350281b /toke.c
parentde9264f424a54109d438d411919d70a2567d5a2a (diff)
downloadperl-fefc93b9ff952105cbd75d4eccd3c8f5864a7323.tar.gz
stringify "\x{FFF}" to utf8 correctly; set SvUTF8 on "\x{XX}"
only when XX > 127 p4raw-id: //depot/perl@5033
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/toke.c b/toke.c
index 3410ab522b..34599bd95f 100644
--- a/toke.c
+++ b/toke.c
@@ -1356,18 +1356,24 @@ S_scan_const(pTHX_ char *start)
++s;
if (*s == '{') {
char* e = strchr(s, '}');
+ UV uv;
if (!e) {
yyerror("Missing right brace on \\x{}");
e = s;
}
/* note: utf always shorter than hex */
- d = (char*)uv_to_utf8((U8*)d,
- (UV)scan_hex(s + 1, e - s - 1, &len));
+ uv = (UV)scan_hex(s + 1, e - s - 1, &len);
+ if (uv > 127) {
+ d = (char*)uv_to_utf8((U8*)d, uv);
+ has_utf = TRUE;
+ }
+ else
+ *d++ = (char)uv;
s = e + 1;
- has_utf = TRUE;
}
else {
+ /* XXX collapse this branch into the one above */
UV uv = (UV)scan_hex(s, 2, &len);
if (utf && PL_lex_inwhat == OP_TRANS &&
utf != (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF))