summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2013-05-22 12:55:50 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2013-05-22 12:55:50 (GMT)
commit75b8011dbad373e664a676ed8e3bcfec70313838 (patch)
tree8b7d5b14cb55b6a6a4f34ebc4a422488ca364f58 /generic
parent5689a75644f9b109581a5dc3ae15294467c657ab (diff)
downloadtcl-75b8011dbad373e664a676ed8e3bcfec70313838.zip
tcl-75b8011dbad373e664a676ed8e3bcfec70313838.tar.gz
tcl-75b8011dbad373e664a676ed8e3bcfec70313838.tar.bz2
Fixed the weird edge case.bug_3613609
Diffstat (limited to 'generic')
-rw-r--r--generic/tclUtf.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index a7a2091..f3d1758 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -1101,31 +1101,44 @@ Tcl_UtfNcasecmp(
}
return 0;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tcl_UtfNcasecmp --
+ *
+ * Compare UTF chars of string cs to string ct case insensitively.
+ * Replacement for strcasecmp in Tcl core, in places where UTF-8 should
+ * be handled.
+ *
+ * Results:
+ * Return <0 if cs < ct, 0 if cs == ct, or >0 if cs > ct.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
-
-/* Replacement for strcasecmp in Tcl core, in places where UTF-8 should be handled. */
int
TclUtfCasecmp(
CONST char *cs, /* UTF string to compare to ct. */
CONST char *ct) /* UTF string cs is compared to. */
{
- Tcl_UniChar ch1, ch2;
- int goOn;
-
- do {
-
- /* If *cs == '\0' or *ct == '\0', loop should end. */
- goOn = *cs && *ct;
+ while (*cs && *ct) {
+ Tcl_UniChar ch1, ch2;
cs += TclUtfToUniChar(cs, &ch1);
ct += TclUtfToUniChar(ct, &ch2);
if (ch1 != ch2) {
ch1 = Tcl_UniCharToLower(ch1);
ch2 = Tcl_UniCharToLower(ch2);
- if (ch1 != ch2) break;
+ if (ch1 != ch2) {
+ return ch1 - ch2;
+ }
}
- } while (goOn);
- return (ch1 - ch2);
+ }
+ return UCHAR(*cs) - UCHAR(*ct);
}