summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
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);
}