diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-03-10 16:16:08 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-03-10 16:16:08 (GMT) |
commit | d0443e229f2951cd4cbc6f94dbfa6f89be95f1b5 (patch) | |
tree | 30f1079c2f0d253e935162d552bb85d03dd64488 /generic/tclUtf.c | |
parent | 07c6dc0d49850424e34bb1666203ac8f0c5b210a (diff) | |
parent | f223db50fda34233096578863259fadfb133e804 (diff) | |
download | tcl-d0443e229f2951cd4cbc6f94dbfa6f89be95f1b5.zip tcl-d0443e229f2951cd4cbc6f94dbfa6f89be95f1b5.tar.gz tcl-d0443e229f2951cd4cbc6f94dbfa6f89be95f1b5.tar.bz2 |
Merge 8.6
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r-- | generic/tclUtf.c | 17 |
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); } } |