summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/utf8.c b/utf8.c
index 52768adef7..71aaf8aa6a 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1287,34 +1287,23 @@ to the hash is by Perl_to_utf8_case().
UV
Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *normal, char *special)
{
- UV uv0, uv1, uv2;
- U8 tmpbuf[UTF8_MAXLEN_FOLD+1];
- STRLEN len;
+ UV uv;
if (!*swashp)
*swashp = swash_init("utf8", normal, &PL_sv_undef, 4, 0);
- uv0 = utf8_to_uvchr(p, 0);
- uv1 = NATIVE_TO_UNI(uv0);
- uvuni_to_utf8(tmpbuf, uv1);
- uv2 = swash_fetch(*swashp, tmpbuf, TRUE);
- if (uv2) {
- /* It was "normal" (single character mapping). */
- uv2 = UNI_TO_NATIVE(uv2);
- len = uvchr_to_utf8(ustrp, uv2) - ustrp;
- if (lenp)
- *lenp = len;
-
- return uv2;
- }
- else {
+ uv = swash_fetch(*swashp, p, TRUE);
+ if (!uv) {
HV *hv;
SV *keysv;
HE *he;
+ uv = utf8_to_uvchr(p, 0);
+
if ((hv = get_hv(special, FALSE)) &&
- (keysv = sv_2mortal(Perl_newSVpvf(aTHX_ "%04"UVXf, uv1))) &&
+ (keysv = sv_2mortal(Perl_newSVpvf(aTHX_ "%04"UVXf, uv))) &&
(he = hv_fetch_ent(hv, keysv, FALSE, 0))) {
SV *val = HeVAL(he);
+ STRLEN len;
char *s = SvPV(val, len);
if (len > 1) {
@@ -1327,6 +1316,8 @@ Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *norma
* mapping, since any characters in the low 256
* are in Unicode code points, not EBCDIC.
* --jhi */
+
+ U8 tmpbuf[UTF8_MAXLEN_FOLD+1];
U8 *d = tmpbuf;
U8 *t, *tend;
@@ -1360,17 +1351,14 @@ Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swashp, char *norma
}
if (lenp)
*lenp = len;
-
return utf8_to_uvchr(ustrp, 0);
}
-
- /* So it was not "special": just copy it. */
- len = uvchr_to_utf8(ustrp, uv0) - ustrp;
- if (lenp)
- *lenp = len;
-
- return uv0;
+ uv = NATIVE_TO_UNI(uv);
}
+ if (lenp)
+ *lenp = UNISKIP(uv);
+ uvuni_to_utf8(ustrp, uv);
+ return uv;
}
/*