diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-03-10 15:47:34 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-03-10 15:47:34 (GMT) |
commit | 07c6dc0d49850424e34bb1666203ac8f0c5b210a (patch) | |
tree | f3028f3e1c36e5a43a02e4a53a04e289f49d0fee /generic/tclUtf.c | |
parent | 764ef9b409175a603666871249e5991dcb7cbd50 (diff) | |
parent | 0834bb45471baf76fe11345ac6893304cd971420 (diff) | |
download | tcl-07c6dc0d49850424e34bb1666203ac8f0c5b210a.zip tcl-07c6dc0d49850424e34bb1666203ac8f0c5b210a.tar.gz tcl-07c6dc0d49850424e34bb1666203ac8f0c5b210a.tar.bz2 |
Merge 8.6
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r-- | generic/tclUtf.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c index e096c06..ef1e74f 100644 --- a/generic/tclUtf.c +++ b/generic/tclUtf.c @@ -1844,25 +1844,24 @@ Tcl_UniCharNcmp( const Tcl_UniChar *uct, /* Unicode string ucs is compared to. */ unsigned long numChars) /* Number of unichars to compare. */ { -#ifdef WORDS_BIGENDIAN - /* - * 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. */ for ( ; numChars != 0; ucs++, uct++, numChars--) { if (*ucs != *uct) { +#if TCL_UTF_MAX < 4 + /* special case for handling upper surrogates */ + if (((*ucs & 0xFC00) == 0xD800) && ((*uct & 0xFC00) != 0xD800)) { + return 1; + } else if (((*uct & 0xFC00) == 0xD800)) { + return -1; + } +#endif return (*ucs - *uct); } } return 0; -#endif /* WORDS_BIGENDIAN */ } /* |