Tcl8.0p2, Tcl8.1a1: BUG+PATCH: lsort -dictionary compares signed chars 
Author Message
 Tcl8.0p2, Tcl8.1a1: BUG+PATCH: lsort -dictionary compares signed chars

        lsort -dictionary compares (possibly) signed chars resulting
in compiler dependent sorting order.  Thus for example longer strings can
compare before shorter strings with same prefix if the first extended char
is not <= 127.

--
        Viktor.

Index: generic/tclCmdIL.c
===================================================================
RCS file: /src/local/repository/usr/local/pkg/tcl8/tcl/generic/tclCmdIL.c,v
retrieving revision 1.3
diff -c -r1.3 tclCmdIL.c
*** tclCmdIL.c  1998/01/26 22:19:13     1.3
--- tclCmdIL.c  1998/01/28 18:48:10
***************
*** 2940,2946 ****
            left += Tcl_UtfToUniChar(left, &uniLeft);
            right += Tcl_UtfToUniChar(right, &uniRight);
        } else {
!           diff = *left - *right;
            break;
        }

--- 2940,2946 ----
            left += Tcl_UtfToUniChar(left, &uniLeft);
            right += Tcl_UtfToUniChar(right, &uniRight);
        } else {
!           diff = (unsigned char) *left - (unsigned char) *right;
            break;
        }

Index: tests/cmdIL.test
===================================================================
RCS file: /src/local/repository/usr/local/pkg/tcl8/tcl/tests/cmdIL.test,v
retrieving revision 1.1.1.2
diff -c -r1.1.1.2 cmdIL.test
*** cmdIL.test  1998/01/26 20:00:23     1.1.1.2
--- cmdIL.test  1998/01/28 19:21:03
***************
*** 263,267 ****
--- 263,305 ----
      restore_locale
      set result
  } "a23\xe3 a23\xe4 a23\xc5"
+ test cmdIL-4.26 {DefaultCompare procedure, signed characters} {
+     set l [lsort [list "abc\200" "abc"]]
+     set viewlist {}
+     foreach s $l {
+       set viewelem ""
+       set len [string length $s]
+       for {set i 0} {$i < $len} {incr i} {
+           set c [string index $s $i]
+           scan $c %c d
+           if {$d > 0 && $d < 128} {
+               append viewelem $c
+           } else {
+               append viewelem "\\[format %03o $d]"
+           }
+       }
+       lappend viewlist $viewelem
+     }
+     set viewlist
+ } [list "abc" "abc\\200"]
+ test cmdIL-4.27 {DictionaryCompare procedure, signed characters} {
+     set l [lsort -dictionary [list "abc\200" "abc"]]
+     set viewlist {}
+     foreach s $l {
+       set viewelem ""
+       set len [string length $s]
+       for {set i 0} {$i < $len} {incr i} {
+           set c [string index $s $i]
+           scan $c %c d
+           if {$d > 0 && $d < 128} {
+               append viewelem $c
+           } else {
+               append viewelem "\\[format %03o $d]"
+           }
+       }
+       lappend viewlist $viewelem
+     }
+     set viewlist
+ } [list "abc" "abc\\200"]

  return



Sun, 16 Jul 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. BUG in lsort -dictionary function in tcl8.0p2

2. Tcl8.1a1 BUGS+PATCH: previously reported 8.0p2 and configuration fixes

3. UPDATED: Tcl8.0p2 BUGS+PATCH: variable related bugs

4. Tcl8.0p2 BUGS+PATCH: variable related bugs

5. Tcl8.0p2 BUG+PATCH: while [cmd] {body} broken and related bugs

6. tcl8.0p2 BUG+PATCH (format %ld %lx etc)

7. Bugs in tcl8.0p2 plus patch

8. tcl8.1a2: Patch for lsort -command

9. TCL8.1a1 Test Failure & Patch

10. Tcl8.0p2: VC++ 5.0 and other misc patches (unified diff format)

11. Bug in tcl8.1a1: format command

12. tcl8.1a1 BUG - checkbuttons

 

 
Powered by phpBB® Forum Software