Artifacts Associated With Ticket 1483802
Ticket change [2dee7b6b6f] (rid 119138) by dansic on 2006-05-08 13:31:01:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Platform: Windows XP When a negative value is given to the -index option of lsort inconsistant behavior do occur. The man page for lsort do not discuss behavior for negative value of -index. One would expect either an empty string being returned or preferably an error be throwned as when the index is out of range. For some negative value a sorted list is return but it seems that the stable property of lsort is lost. For some other value a list is returned but whitout any discernible sorting. Finally for some others value an error is throwned. The error is the same as for an out of range positive value for -index. Example: (bin) 94 % set list2 {{5 4 6} {10 12 11} {2 3 1} {5 7 1}} {5 4 6} {10 12 11} {2 3 1} {5 7 1} (bin) 95 % lsort -dictionary -index 2 $list2 {2 3 1} {5 7 1} {5 4 6} {10 12 11} (bin) 96 % lsort -dictionary -index -2 $list2 {2 3 1} {5 7 1} {5 4 6} {10 12 11} (bin) 97 % lsort -dictionary -index -3 $list2 {2 3 1} {5 4 6} {5 7 1} {10 12 11} (bin) 98 % lsort -dictionary -index 3 $list2 element 3 missing from sublist "5 4 6" (bin) 99 % lsort -dictionary -index -4 $list2 {2 3 1} {5 4 6} {5 7 1} {10 12 11} (bin) 100 % lsort -dictionary -index -5 $list2 element -5 missing from sublist "5 4 6" (bin) 101 % lsort -dictionary -index -1 $list2 {2 3 1} {5 4 6} {5 7 1} {10 12 11} (bin) 104 % set list3 {{5 2 3 4 3} {3 6 9 2 7} {5 1 12 13 15} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5}} {5 2 3 4 3} {3 6 9 2 7} {5 1 12 13 15} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5} (bin) 105 % lsort -dictionary -index 0 $list3 {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 2 3 4 3} {5 1 12 13 15} {9 3 34 12 3} (bin) 106 % lsort -dictionary -index 1 $list3 {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} (bin) 107 % lsort -dictionary -index -1 $list3 {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} (bin) 108 % lsort -dictionary -index 2 $list3 {5 2 3 4 3} {4 9 3 6 5} {3 6 9 2 7} {5 1 12 13 15} {1 3 32 24 5} {9 3 34 12 3} (bin) 109 % lsort -dictionary -index -2 $list3 {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5} {3 6 9 2 7} {5 1 12 13 15} (bin) 110 % lsort -dictionary -index 3 $list3 {3 6 9 2 7} {5 2 3 4 3} {4 9 3 6 5} {9 3 34 12 3} {5 1 12 13 15} {1 3 32 24 5} (bin) 111 % lsort -dictionary -index -3 $list3 {3 6 9 2 7} {5 2 3 4 3} {4 9 3 6 5} {9 3 34 12 3} {5 1 12 13 15} {1 3 32 24 5} (bin) 112 % lsort -dictionary -index 4 $list3 {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5} {3 6 9 2 7} {5 1 12 13 15} (bin) 113 % lsort -dictionary -index -4 $list3 {5 2 3 4 3} {4 9 3 6 5} {3 6 9 2 7} {5 1 12 13 15} {1 3 32 24 5} {9 3 34 12 3} (bin) 114 % lsort -dictionary -index 5 $list3 element 5 missing from sublist "5 2 3 4 3" (bin) 115 % lsort -dictionary -index -5 $list3 {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} (bin) 116 % lsort -dictionary -index 6 $list3 element 6 missing from sublist "5 2 3 4 3" (bin) 117 % lsort -dictionary -index -6 $list3 {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 2 3 4 3} {5 1 12 13 15} {9 3 34 12 3} (bin) 118 % lsort -dictionary -index 7 $list3 element 7 missing from sublist "5 2 3 4 3" (bin) 119 % lsort -dictionary -index -7 $list3 element -7 missing from sublist "5 2 3 4 3" (bin) 120 % lsort -index 0 $list3 {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 2 3 4 3} {5 1 12 13 15} {9 3 34 12 3} (bin) 121 % lsort -index 1 $list3 {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} (bin) 122 % lsort -index -1 $list3 {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} (bin) 123 % lsort -index 2 $list3 {5 1 12 13 15} {5 2 3 4 3} {4 9 3 6 5} {1 3 32 24 5} {9 3 34 12 3} {3 6 9 2 7} (bin) 124 % lsort -index -2 $list3 {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5} {3 6 9 2 7} (bin) 125 % lsort -index 3 $list3 {9 3 34 12 3} {5 1 12 13 15} {3 6 9 2 7} {1 3 32 24 5} {5 2 3 4 3} {4 9 3 6 5} (bin) 126 % lsort -index -3 $list3 {9 3 34 12 3} {5 1 12 13 15} {3 6 9 2 7} {1 3 32 24 5} {5 2 3 4 3} {4 9 3 6 5} (bin) 127 % lsort -index 4 $list3 {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {4 9 3 6 5} {3 6 9 2 7} (bin) 128 % lsort -index -4 $list3 {5 1 12 13 15} {5 2 3 4 3} {4 9 3 6 5} {1 3 32 24 5} {9 3 34 12 3} {3 6 9 2 7} (bin) 129 % lsort -index 5 $list3 element 5 missing from sublist "5 2 3 4 3" (bin) 130 % lsort -index -5 $list3 {5 1 12 13 15} {5 2 3 4 3} {9 3 34 12 3} {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} (bin) 131 % lsort -index 6 $list3 element 6 missing from sublist "5 2 3 4 3" (bin) 132 % lsort -index -6 $list3 {1 3 32 24 5} {3 6 9 2 7} {4 9 3 6 5} {5 2 3 4 3} {5 1 12 13 15} {9 3 34 12 3} (bin) 133 % lsort -index 7 $list3 element 7 missing from sublist "5 2 3 4 3" (bin) 134 % lsort -index -7 $list3 element -7 missing from sublist "5 2 3 4 3" - foundin initialized to: "obsolete: 8.4.11"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dansic"
- subsystem initialized to: "17. Commands I-L"
- title initialized to:
lsort inconsistant behavior for negative value of -index
- type initialized to: "Bug"
Ticket change [236dd5f19f] (rid 130931) by mic42 on 2006-08-02 15:11:12:
- icomment:
Logged In: YES user_id=302287 This is an artifact from using TclGetIntFromIndex() on the index, which uses negative indices to indicate an end relative index. As TclGetIntFromIndex() allows negative values for indices this is would probably either require a specialized TclGetIntFromIndex() which guards against negative indices other than end relative indices..., or one extra call to Tcl_GetIntFromObj() first (which is also done at the beginning of TclGetIntFromIndex()), with a check for negative values.
- login: "mic42"
- mimetype: "text/plain"
- username: "mic42"
- icomment:
Ticket change [811bd42d2d] (rid 116981) by dkf on 2006-08-04 00:16:05:
- assignee changed to: "hobbs"
- subsystem changed to: "10. Objects"
Ticket change [1bafbcc27e] (rid 259713) by serhiy.storchaka on 2026-10-21 10:03:37:
- icomment:
Fixed in 8.6.9 by [71c0a83836] (ticket [db36fa5122]): negative <tt>-index</tt> values now raise an error instead of being taken as end-relative.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- icomment:
Ticket change [fafe79b803] (rid 260008) by serhiy.storchaka on 2026-10-22 17:19:30:
- closedate changed to: "2461334.9191789697"
- closer changed to: "serhiy.storchaka"
- login: "serhiy.storchaka"