View Ticket
2015-04-13
03:01 New ticket [2566f06210] addition to [00bc6a8fb5e8]. artifact: 0ec346fe50 user: anonymous
02:54 New ticket [00bc6a8fb5] use package vcompare instead of dictionary sort for package versions. artifact: dc1581b36e user: anonymous

Ticket Hash: 00bc6a8fb5e894a7480d154af8e14ea8d269560a
Title: use [package vcompare] instead of dictionary sort for package versions
Status: Open Type: Code_Defect
Severity: Severe Priority:
Subsystem: Resolution:
Last Modified: 2015-04-13 02:54:10
Version Found In: trunk
User Comments:
anonymous added on 2015-04-13 02:54:10:
teapot-client uses [lsort -dictionary] to determine the newest package
version, which is incorrect (case in point: tdbc).

The following patch fixes this AND inclides a workaround for vectcl
http://teapot.rkeene.org/entity/name/vectcl/index.html which doesn't
conform to [package vcompare].  The latter should surely be fixed:  ActiveState's teapot knows it only as "0.1".


Index: client/lib/teapotclient0.1/teapotclient.tcl
==================================================================
--- client/lib/teapotclient0.1/teapotclient.tcl
+++ client/lib/teapotclient0.1/teapotclient.tcl
@@ -340,17 +340,29 @@
 
                        lappend pkginfo($pkg) [list $ver $arch]
                }
 
                foreach pkg [array names pkginfo] {
-                       set pkginfo($pkg) [lsort -decreasing -dictionary $pkginfo($pkg)]
+                       set pkginfo($pkg) [lsort -decreasing -command ::teapotclient::vcompare $pkginfo($pkg)]
                }
 
                return [array get pkginfo]
        }
 
        proc setcachedir {dir} {
                set ::teapotclient::pkgcachedir $dir
        }
+
+       proc vcompare {a b} {
+               try {
+                       package vcompare $a $b
+               } on error {} {
+                       try {
+                               package vcompare [lindex $a 0] [lindex $b 0]
+                       } on error {} {
+                               string compare -nocase $a $b
+                       }
+               }
+       }
 }
 
 package provide teapotclient 0.1

Index: client/teapot-client.tcl
==================================================================
--- client/teapot-client.tcl
+++ client/teapot-client.tcl
@@ -88,15 +88,15 @@
                                set extinfoitemvers [lindex $extinfoitem 0]
                                if {[lsearch -exact $extvers $extinfoitemvers] == -1} {
                                        lappend extvers $extinfoitemvers
                                }
                        }
-                       set extvers [lsort -decreasing -dictionary $extvers]
+                       set extvers [lsort -decreasing -command ::teapotclient::vcompare $extvers]
 
                        puts "  $ext [lindex $extvers 0]"
                }
        }
        default {
                print_help
                exit 1
        }
 }