summaryrefslogtreecommitdiffstats
path: root/generic/tclUtf.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-03-10 16:16:08 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-03-10 16:16:08 (GMT)
commitd0443e229f2951cd4cbc6f94dbfa6f89be95f1b5 (patch)
tree30f1079c2f0d253e935162d552bb85d03dd64488 /generic/tclUtf.c
parent07c6dc0d49850424e34bb1666203ac8f0c5b210a (diff)
parentf223db50fda34233096578863259fadfb133e804 (diff)
downloadtcl-d0443e229f2951cd4cbc6f94dbfa6f89be95f1b5.zip
tcl-d0443e229f2951cd4cbc6f94dbfa6f89be95f1b5.tar.gz
tcl-d0443e229f2951cd4cbc6f94dbfa6f89be95f1b5.tar.bz2
Merge 8.6
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r--generic/tclUtf.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index ef1e74f..d2b4187 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -1844,6 +1844,14 @@ Tcl_UniCharNcmp(
const Tcl_UniChar *uct, /* Unicode string ucs is compared to. */
unsigned long numChars) /* Number of unichars to compare. */
{
+#if defined(WORDS_BIGENDIAN) && (TCL_UTF_MAX > 3)
+ /*
+ * We are definitely on a big-endian machine; memcmp() is safe
+ */
+
+ return memcmp(ucs, uct, numChars*sizeof(Tcl_UniChar));
+
+#else /* !WORDS_BIGENDIAN */
/*
* We can't simply call memcmp() because that is not lexically correct.
*/
@@ -1862,6 +1870,7 @@ Tcl_UniCharNcmp(
}
}
return 0;
+#endif /* WORDS_BIGENDIAN */
}
/*
@@ -1894,6 +1903,14 @@ Tcl_UniCharNcasecmp(
Tcl_UniChar lct = Tcl_UniCharToLower(*uct);
if (lcs != lct) {
+#if TCL_UTF_MAX < 4
+ /* special case for handling upper surrogates */
+ if (((lcs & 0xFC00) == 0xD800) && ((lct & 0xFC00) != 0xD800)) {
+ return 1;
+ } else if (((lct & 0xFC00) == 0xD800)) {
+ return -1;
+ }
+#endif
return (lcs - lct);
}
}