summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-03-03 19:19:42 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-03-03 19:19:42 +0000
commit8973db79328a885c91b9dfdcafdb28dbe9e65a88 (patch)
treed6d992600192764a3ae09df1bb2d021e39a2f95e /toke.c
parent830ec763789df5f5b0683aa3c9e6ad3d5e5f2fd7 (diff)
downloadperl-8973db79328a885c91b9dfdcafdb28dbe9e65a88.tar.gz
UTF8 tr/// fixes from Inaba Hiroto.
p4raw-id: //depot/perl@9008
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/toke.c b/toke.c
index 33915ed42a..daa0d52be6 100644
--- a/toke.c
+++ b/toke.c
@@ -1240,6 +1240,17 @@ S_scan_const(pTHX_ char *start)
I32 min; /* first character in range */
I32 max; /* last character in range */
+ if (utf) {
+ char *c = (char*)utf8_hop((U8*)d, -1);
+ char *e = d++;
+ while (e-- > c)
+ *(e + 1) = *e;
+ *c = 0xff;
+ /* mark the range as done, and continue */
+ dorange = FALSE;
+ didrange = TRUE;
+ continue;
+ }
i = d - SvPVX(sv); /* remember current offset */
SvGROW(sv, SvLEN(sv) + 256); /* never more than 256 chars in a range */
d = SvPVX(sv) + i; /* refresh d after realloc */
@@ -1466,7 +1477,7 @@ S_scan_const(pTHX_ char *start)
char *src, *dst;
d = SvGROW(sv,
- SvCUR(sv) + hicount + 1) +
+ SvLEN(sv) + hicount + 1) +
(d - old_pvx);
src = d - 1;
@@ -1539,7 +1550,7 @@ S_scan_const(pTHX_ char *start)
if (len > e - s + 4) {
char *odest = SvPVX(sv);
- SvGROW(sv, (SvCUR(sv) + len - (e - s + 4)));
+ SvGROW(sv, (SvLEN(sv) + len - (e - s + 4)));
d = SvPVX(sv) + (d - odest);
}
Copy(str, d, len, char);
@@ -6303,9 +6314,6 @@ S_scan_trans(pTHX_ char *start)
Perl_croak(aTHX_ "Transliteration replacement not terminated");
}
- New(803,tbl,256,short);
- o = newPVOP(OP_TRANS, 0, (char*)tbl);
-
complement = del = squash = 0;
while (strchr("cds", *s)) {
if (*s == 'c')
@@ -6316,6 +6324,9 @@ S_scan_trans(pTHX_ char *start)
squash = OPpTRANS_SQUASH;
s++;
}
+
+ New(803, tbl, complement&&!del?258:256, short);
+ o = newPVOP(OP_TRANS, 0, (char*)tbl);
o->op_private = del|squash|complement|
(DO_UTF8(PL_lex_stuff)? OPpTRANS_FROM_UTF : 0)|
(DO_UTF8(PL_lex_repl) ? OPpTRANS_TO_UTF : 0);