summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-01-01 03:35:01 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-01-01 03:35:01 +0000
commitffce6cc29631cbe46068af7601780981e4969f2a (patch)
tree22070032294df853b24e3fa8835468d85a183fab /utf8.c
parent99f22665d16e539ac96fd8697c65cfa96010d82d (diff)
downloadperl-ffce6cc29631cbe46068af7601780981e4969f2a.tar.gz
Unnecessary/Lingering UTF8 flag might mess up caseless matching
(found by Jeffrey Friedl) p4raw-id: //depot/perl@13992
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/utf8.c b/utf8.c
index 54ab5293cc..0051796840 100644
--- a/utf8.c
+++ b/utf8.c
@@ -1672,9 +1672,9 @@ Perl_ibcmp_utf8(pTHX_ const char *s1, bool u1, register I32 len1, const char *s2
register U8 *be = b + len2;
STRLEN la, lb;
UV ca, cb;
- STRLEN ulen1, ulen2;
- U8 tmpbuf1[UTF8_MAXLEN_FOLD+1];
- U8 tmpbuf2[UTF8_MAXLEN_FOLD+1];
+ STRLEN foldlen1, foldlen2;
+ U8 foldbuf1[UTF8_MAXLEN_FOLD+1];
+ U8 foldbuf2[UTF8_MAXLEN_FOLD+1];
while (a < ae && b < be) {
if (u1) {
@@ -1682,7 +1682,7 @@ Perl_ibcmp_utf8(pTHX_ const char *s1, bool u1, register I32 len1, const char *s2
break;
ca = utf8_to_uvchr((U8*)a, &la);
} else {
- ca = *a;
+ ca = NATIVE_TO_UNI(*a);
la = 1;
}
if (u2) {
@@ -1690,21 +1690,17 @@ Perl_ibcmp_utf8(pTHX_ const char *s1, bool u1, register I32 len1, const char *s2
break;
cb = utf8_to_uvchr((U8*)b, &lb);
} else {
- cb = *b;
+ cb = NATIVE_TO_UNI(*b);
lb = 1;
}
if (ca != cb) {
- if (u1)
- to_uni_fold(NATIVE_TO_UNI(ca), tmpbuf1, &ulen1);
- else
- ulen1 = 1;
- if (u2)
- to_uni_fold(NATIVE_TO_UNI(cb), tmpbuf2, &ulen2);
- else
- ulen2 = 1;
- if (ulen1 != ulen2
- || (ca < 256 && cb < 256 && ca != PL_fold[cb])
- || memNE((char *)tmpbuf1, (char *)tmpbuf2, ulen1))
+ to_uni_fold(ca, foldbuf1, &foldlen1);
+ ca = utf8_to_uvchr(foldbuf1, 0);
+
+ to_uni_fold(cb, foldbuf2, &foldlen2);
+ cb = utf8_to_uvchr(foldbuf2, 0);
+
+ if (ca != cb || foldlen1 != foldlen2)
return 1; /* mismatch */
}
a += la;