summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericm <ericm>2000-01-13 20:33:09 (GMT)
committerericm <ericm>2000-01-13 20:33:09 (GMT)
commit2df683089994bc1bbc39f633ddbfa92a57b0024f (patch)
tree2ab75593da54c94ef8f64f640eb3be3aa97d00aa
parentdee657ae620fbab5edb1f2fd5a11452a61b605ba (diff)
downloadtcl-2df683089994bc1bbc39f633ddbfa92a57b0024f.zip
tcl-2df683089994bc1bbc39f633ddbfa92a57b0024f.tar.gz
tcl-2df683089994bc1bbc39f633ddbfa92a57b0024f.tar.bz2
* tests/cmdIL.test: Added tests for lsort -dictionary with
characters that occur between Z and a in ASCII. * generic/tclCmdIL.c: Modified DictionaryCompare function (used by lsort -dictionary) to do upper/lower case equivalency before doing character comparisons, instead of after. This fixes bug #1357, in which lsort -dictionary [list ` AA c CC] and lsort -dictionary [list AA c ` CC] gave different (and both wrong) results.
-rw-r--r--ChangeLog15
-rw-r--r--generic/tclCmdIL.c34
-rw-r--r--tests/cmdIL.test20
3 files changed, 50 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index b784ea7..5517efb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
+2000-01-13 Eric Melski <ericm@scriptics.com>
+
+ * tests/cmdIL.test: Added tests for lsort -dictionary with
+ characters that occur between Z and a in ASCII.
+
+ * generic/tclCmdIL.c: Modified DictionaryCompare function (used by
+ lsort -dictionary) to do upper/lower case equivalency before doing
+ character comparisons, instead of after. This fixes bug #1357, in
+ which lsort -dictionary [list ` AA c CC] and lsort -dictionary
+ [list AA c ` CC] gave different (and both wrong) results.
+
2000-01-12 Eric Melski <ericm@scriptics.com>
+ * tests/clock.test: Added tests for "next <day-of-week>" and
+ "<day-of-week>"
+ Added tests for "monday 1 week ago", etc, from RFE #3671.
+
* doc/tests/clock.test: Added numerous tests for clock scan.
* doc/generic/tclGetDate.y: Fixed some shift/reduce conflicts in
diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c
index bacf7e6..4fe4f4a 100644
--- a/generic/tclCmdIL.c
+++ b/generic/tclCmdIL.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclCmdIL.c,v 1.20 2000/01/12 11:12:52 hobbs Exp $
+ * RCS: @(#) $Id: tclCmdIL.c,v 1.21 2000/01/13 20:33:10 ericm Exp $
*/
#include "tclInt.h"
@@ -2991,7 +2991,7 @@ static int
DictionaryCompare(left, right)
char *left, *right; /* The strings to compare */
{
- Tcl_UniChar uniLeft, uniRight;
+ Tcl_UniChar uniLeft, uniRight, uniLeftLower, uniRightLower;
int diff, zeros;
int secondaryDiff = 0;
@@ -3063,32 +3063,30 @@ DictionaryCompare(left, right)
if ((*left != '\0') && (*right != '\0')) {
left += Tcl_UtfToUniChar(left, &uniLeft);
right += Tcl_UtfToUniChar(right, &uniRight);
+ /*
+ * Convert both chars to lower for the comparison, because
+ * dictionary sorts are case insensitve. Covert to lower, not
+ * upper, so chars between Z and a will sort before A (where most
+ * other interesting punctuations occur)
+ */
+ uniLeftLower = Tcl_UniCharToLower(uniLeft);
+ uniRightLower = Tcl_UniCharToLower(uniRight);
} else {
diff = UCHAR(*left) - UCHAR(*right);
break;
}
- diff = uniLeft - uniRight;
+ diff = uniLeftLower - uniRightLower;
if (diff) {
+ return diff;
+ } else if (secondaryDiff == 0) {
if (Tcl_UniCharIsUpper(uniLeft) &&
Tcl_UniCharIsLower(uniRight)) {
- diff = Tcl_UniCharToLower(uniLeft) - uniRight;
- if (diff) {
- return diff;
- } else if (secondaryDiff == 0) {
- secondaryDiff = -1;
- }
+ secondaryDiff = -1;
} else if (Tcl_UniCharIsUpper(uniRight)
&& Tcl_UniCharIsLower(uniLeft)) {
- diff = uniLeft - Tcl_UniCharToLower(uniRight);
- if (diff) {
- return diff;
- } else if (secondaryDiff == 0) {
- secondaryDiff = 1;
- }
- } else {
- return diff;
- }
+ secondaryDiff = 1;
+ }
}
}
if (diff == 0) {
diff --git a/tests/cmdIL.test b/tests/cmdIL.test
index 7e53974..34d44df 100644
--- a/tests/cmdIL.test
+++ b/tests/cmdIL.test
@@ -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: cmdIL.test,v 1.10 1999/12/21 23:58:22 hobbs Exp $
+# RCS: @(#) $Id: cmdIL.test,v 1.11 2000/01/13 20:33:10 ericm Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -315,6 +315,24 @@ test cmdIL-4.27 {DictionaryCompare procedure, signed characters} {
}
set viewlist
} [list "abc" "abc\\200"]
+test cmdIL-4.28 {DictionaryCompare procedure, chars between Z and a in ASCII} {
+ lsort -dictionary [list AA ` c CC]
+} [list ` AA c CC]
+test cmdIL-4.29 {DictionaryCompare procedure, chars between Z and a in ASCII} {
+ lsort -dictionary [list AA ` c ^ \\ CC \[ \]]
+} [list \[ \\ \] ^ ` AA c CC]
+test cmdIL-4.30 {DictionaryCompare procedure, chars between Z and a in ASCII} {
+ lsort -dictionary [list AA ` c ^ _ \\ CC \[ dude \] funky]
+} [list \[ \\ \] ^ _ ` AA c CC dude funky]
+test cmdIL-4.31 {DictionaryCompare procedure, chars between Z and a in ASCII} {
+ lsort -dictionary [list AA c ` CC]
+} [list ` AA c CC]
+test cmdIL-4.32 {DictionaryCompare procedure, chars between Z and a in ASCII} {
+ lsort -dictionary [list AA c CC `]
+} [list ` AA c CC]
+test cmdIL-4.33 {DictionaryCompare procedure, chars between Z and a in ASCII} {
+ lsort -dictionary [list AA ! c CC `]
+} [list ! ` AA c CC]
# cleanup
::tcltest::cleanupTests