diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-03-19 20:59:37 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 2001-03-19 20:59:37 +0000 |
commit | f2f6ab5ed2d2f824b4f6c3085a4a2275c2f8500a (patch) | |
tree | 9c4ade8213cf4bb730b5a2f1eb82b8644cb1ce57 /doop.c | |
parent | 1e0e26cb26fde01fd11e7cf9703ff3045aed4e51 (diff) | |
parent | 982b7775e1ad97c44654b5fd0132bfeb9eacc46e (diff) | |
download | perl-f2f6ab5ed2d2f824b4f6c3085a4a2275c2f8500a.tar.gz |
Integrate mainline.
p4raw-id: //depot/perlio@9249
Diffstat (limited to 'doop.c')
-rw-r--r-- | doop.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -404,6 +404,7 @@ S_do_trans_count_utf8(pTHX_ SV *sv)/* SPC - OK */ HV* hv = (HV*)SvRV(rv); SV** svp = hv_fetch(hv, "NONE", 4, FALSE); UV none = svp ? SvUV(*svp) : 0x7fffffff; + UV extra = none + 1; UV uv; U8 hibit = 0; @@ -421,7 +422,7 @@ S_do_trans_count_utf8(pTHX_ SV *sv)/* SPC - OK */ send = s + len; while (s < send) { - if ((uv = swash_fetch(rv, s)) < none) + if ((uv = swash_fetch(rv, s)) < none || uv == extra) matches++; s += UTF8SKIP(s); } @@ -447,6 +448,7 @@ S_do_trans_complex_utf8(pTHX_ SV *sv) /* SPC - NOT OK */ UV none = svp ? SvUV(*svp) : 0x7fffffff; UV extra = none + 1; UV final; + bool havefinal = FALSE; UV uv; STRLEN len; U8 *dstart, *dend; @@ -469,8 +471,10 @@ S_do_trans_complex_utf8(pTHX_ SV *sv) /* SPC - NOT OK */ start = s; svp = hv_fetch(hv, "FINAL", 5, FALSE); - if (svp) + if (svp) { final = SvUV(*svp); + havefinal = TRUE; + } if (grows) { /* d needs to be bigger than s, in case e.g. upgrading is required */ @@ -516,10 +520,22 @@ S_do_trans_complex_utf8(pTHX_ SV *sv) /* SPC - NOT OK */ } else if (uv == extra && !del) { matches++; - s += UTF8SKIP(s); - if (uv != puv) { - d = uvchr_to_utf8(d, final); - puv = final; + if (havefinal) { + s += UTF8SKIP(s); + if (puv != final) { + d = uvchr_to_utf8(d, final); + puv = final; + } + } + else { + STRLEN len; + uv = utf8_to_uvchr(s, &len); + if (uv != puv) { + Copy(s, d, len, U8); + d += len; + puv = uv; + } + s += len; } continue; } |