summaryrefslogtreecommitdiffstats
path: root/generic/tclUtf.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-05-28 07:25:32 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-05-28 07:25:32 (GMT)
commite73451abd4345c7ac70b5765ef7dacb44dea323e (patch)
tree5d3f427b2f6e12efb63448f4224528fbefeabb0a /generic/tclUtf.c
parent3db39eda8ac36d1df59d1dd1960c9d4c0a60c346 (diff)
parent251b09c99a919401499cbff4183ff4fcccdd993d (diff)
downloadtcl-e73451abd4345c7ac70b5765ef7dacb44dea323e.zip
tcl-e73451abd4345c7ac70b5765ef7dacb44dea323e.tar.gz
tcl-e73451abd4345c7ac70b5765ef7dacb44dea323e.tar.bz2
merge trunk
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r--generic/tclUtf.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 891c0ff..014413a 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -1106,6 +1106,46 @@ Tcl_UtfNcasecmp(
/*
*----------------------------------------------------------------------
*
+ * 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.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TclUtfCasecmp(
+ const char *cs, /* UTF string to compare to ct. */
+ const char *ct) /* UTF string cs is compared to. */
+{
+ 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) {
+ return ch1 - ch2;
+ }
+ }
+ }
+ return UCHAR(*cs) - UCHAR(*ct);
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_UniCharToUpper --
*
* Compute the uppercase equivalent of the given Unicode character.