summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2003-03-06 23:27:12 (GMT)
committerdgp <dgp@users.sourceforge.net>2003-03-06 23:27:12 (GMT)
commit717a75ea043e247d252c17e9c0e9ac8243a2fa8a (patch)
treeb1a72619f7dd43be739320a272719b7c91030da7
parent894d26e115f83b973c3a3c31d7e5ccab5e604779 (diff)
downloadtcl-717a75ea043e247d252c17e9c0e9ac8243a2fa8a.zip
tcl-717a75ea043e247d252c17e9c0e9ac8243a2fa8a.tar.gz
tcl-717a75ea043e247d252c17e9c0e9ac8243a2fa8a.tar.bz2
* generic/TclUtf.c (Tcl_UniCharNcasecmp): Corrected failure to
* tests/utf.test (utf-25.*): properly compare Unicode strings of different case in a case insensitive manner. [Bug 699042]
-rw-r--r--ChangeLog6
-rw-r--r--generic/tclUtf.c11
-rw-r--r--tests/utf.test38
3 files changed, 49 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index fd12930..fb72913 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2003-03-06 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/TclUtf.c (Tcl_UniCharNcasecmp): Corrected failure to
+ * tests/utf.test (utf-25.*): properly compare Unicode strings of
+ different case in a case insensitive manner. [Bug 699042]
+
2003-03-06 Kevin Kenny <kennykb@users.sourceforge.net>
* generic/tclCompCmds.c (TclCompileSwitchCmd):
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 6c6835c..2e464ed 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUtf.c,v 1.30 2003/02/18 02:25:45 hobbs Exp $
+ * RCS: @(#) $Id: tclUtf.c,v 1.31 2003/03/06 23:27:14 dgp Exp $
*/
#include "tclInt.h"
@@ -1294,9 +1294,12 @@ Tcl_UniCharNcasecmp(cs, ct, n)
unsigned long n; /* Number of unichars to compare. */
{
for ( ; n != 0; n--, cs++, ct++) {
- if ((*cs != *ct) &&
- (Tcl_UniCharToLower(*cs) != Tcl_UniCharToLower(*ct))) {
- return (*cs - *ct);
+ if (*cs != *ct) {
+ Tcl_UniChar lcs = Tcl_UniCharToLower(*cs);
+ Tcl_UniChar lct = Tcl_UniCharToLower(*ct);
+ if (lcs != lct) {
+ return (lcs - lct);
+ }
}
}
return 0;
diff --git a/tests/utf.test b/tests/utf.test
index 0ba2414..0e1b315 100644
--- a/tests/utf.test
+++ b/tests/utf.test
@@ -8,10 +8,10 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: utf.test,v 1.8 2001/05/28 04:31:14 hobbs Exp $
+# RCS: @(#) $Id: utf.test,v 1.9 2003/03/06 23:27:14 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
- package require tcltest
+ package require tcltest 2
namespace import -force ::tcltest::*
}
@@ -299,6 +299,40 @@ test utf-24.2 {unicode space char in regc_locale.c} {
list [regexp {^[[:space:]]+$} \u1680] [regexp {^\s+$} \u1680]
} {1 1}
+testConstraint teststringobj [llength [info commands teststringobj]]
+test utf-25.1 {Tcl_UniCharNcasecmp} teststringobj {
+ testobj freeallvars
+ teststringobj set 1 a
+ teststringobj set 2 b
+ teststringobj getunicode 1
+ teststringobj getunicode 2
+ string compare -nocase [teststringobj get 1] [teststringobj get 2]
+} -1
+test utf-25.2 {Tcl_UniCharNcasecmp} teststringobj {
+ testobj freeallvars
+ teststringobj set 1 b
+ teststringobj set 2 a
+ teststringobj getunicode 1
+ teststringobj getunicode 2
+ string compare -nocase [teststringobj get 1] [teststringobj get 2]
+} 1
+test utf-25.3 {Tcl_UniCharNcasecmp} teststringobj {
+ testobj freeallvars
+ teststringobj set 1 B
+ teststringobj set 2 a
+ teststringobj getunicode 1
+ teststringobj getunicode 2
+ string compare -nocase [teststringobj get 1] [teststringobj get 2]
+} 1
+test utf-25.4 {Tcl_UniCharNcasecmp} teststringobj {
+ testobj freeallvars
+ teststringobj set 1 aBcB
+ teststringobj set 2 abca
+ teststringobj getunicode 1
+ teststringobj getunicode 2
+ string compare -nocase [teststringobj get 1] [teststringobj get 2]
+} 1
+
# cleanup
::tcltest::cleanupTests
return