From: Jarkko Hietaniemi Date: Sun, 1 Apr 2001 05:55:46 +0000 (+0000) Subject: tr/// UTF-8 tweaking from Inaba Hiroto. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf4a1e57418e4e968df2de0a68b966c25d5da8ea;p=p5sagit%2Fp5-mst-13.2.git tr/// UTF-8 tweaking from Inaba Hiroto. p4raw-id: //depot/perl@9499 --- diff --git a/embed.h b/embed.h index c8015c5..8ec511b 100644 --- a/embed.h +++ b/embed.h @@ -909,7 +909,6 @@ #define scalarboolean S_scalarboolean #define too_few_arguments S_too_few_arguments #define too_many_arguments S_too_many_arguments -#define trlist_upgrade S_trlist_upgrade #define op_clear S_op_clear #define null S_null #define pad_addlex S_pad_addlex @@ -2393,7 +2392,6 @@ #define scalarboolean(a) S_scalarboolean(aTHX_ a) #define too_few_arguments(a,b) S_too_few_arguments(aTHX_ a,b) #define too_many_arguments(a,b) S_too_many_arguments(aTHX_ a,b) -#define trlist_upgrade(a,b) S_trlist_upgrade(aTHX_ a,b) #define op_clear(a) S_op_clear(aTHX_ a) #define null(a) S_null(aTHX_ a) #define pad_addlex(a) S_pad_addlex(aTHX_ a) @@ -4681,8 +4679,6 @@ #define too_few_arguments S_too_few_arguments #define S_too_many_arguments CPerlObj::S_too_many_arguments #define too_many_arguments S_too_many_arguments -#define S_trlist_upgrade CPerlObj::S_trlist_upgrade -#define trlist_upgrade S_trlist_upgrade #define S_op_clear CPerlObj::S_op_clear #define op_clear S_op_clear #define S_null CPerlObj::S_null diff --git a/embed.pl b/embed.pl index 552c0a5..3682192 100755 --- a/embed.pl +++ b/embed.pl @@ -2292,7 +2292,6 @@ s |OP* |no_fh_allowed |OP *o s |OP* |scalarboolean |OP *o s |OP* |too_few_arguments|OP *o|char* name s |OP* |too_many_arguments|OP *o|char* name -s |U8* |trlist_upgrade |U8** sp|U8** ep s |void |op_clear |OP* o s |void |null |OP* o s |PADOFFSET|pad_addlex |SV* name diff --git a/op.c b/op.c index 88d773c..155f107 100644 --- a/op.c +++ b/op.c @@ -103,30 +103,6 @@ S_no_bareword_allowed(pTHX_ OP *o) SvPV_nolen(cSVOPo_sv))); } -STATIC U8* -S_trlist_upgrade(pTHX_ U8** sp, U8** ep) -{ - U8 *s = *sp; - U8 *e = *ep; - U8 *d; - - Newz(801, d, (e - s) * 2, U8); - *sp = d; - - while (s < e) { - if (NATIVE_IS_INVARIANT(*s) || NATIVE_TO_UTF(*s) == 0xff) - *d++ = *s++; - else { - U8 c = NATIVE_TO_ASCII(*s++); - *d++ = UTF8_EIGHT_BIT_HI(c); - *d++ = UTF8_EIGHT_BIT_LO(c); - } - } - *ep = d; - return *sp; -} - - /* "register" allocation */ PADOFFSET @@ -2708,8 +2684,19 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl) U32 final; I32 from_utf = o->op_private & OPpTRANS_FROM_UTF; I32 to_utf = o->op_private & OPpTRANS_TO_UTF; - U8* tsave = from_utf ? NULL : trlist_upgrade(&t, &tend); - U8* rsave = (to_utf || !rlen) ? NULL : trlist_upgrade(&r, &rend); + U8* tsave = NULL; + U8* rsave = NULL; + + if (!from_utf) { + STRLEN len = tlen; + tsave = t = bytes_to_utf8(t, &len); + tend = t + len; + } + if (!to_utf && rlen) { + STRLEN len = rlen; + rsave = r = bytes_to_utf8(r, &len); + rend = r + len; + } /* There are several snags with this code on EBCDIC: 1. 0xFF is a legal UTF-EBCDIC byte (there are no illegal bytes). diff --git a/proto.h b/proto.h index 9be4cd7..c8a59a4 100644 --- a/proto.h +++ b/proto.h @@ -1023,7 +1023,6 @@ STATIC OP* S_no_fh_allowed(pTHX_ OP *o); STATIC OP* S_scalarboolean(pTHX_ OP *o); STATIC OP* S_too_few_arguments(pTHX_ OP *o, char* name); STATIC OP* S_too_many_arguments(pTHX_ OP *o, char* name); -STATIC U8* S_trlist_upgrade(pTHX_ U8** sp, U8** ep); STATIC void S_op_clear(pTHX_ OP* o); STATIC void S_null(pTHX_ OP* o); STATIC PADOFFSET S_pad_addlex(pTHX_ SV* name);