5 .HLL 'Tcl', 'tcl_group'
9 .param pmc argv :slurpy
11 .local int return_type, argc
17 if argc == 0 goto wrong_args
19 compare = get_root_global ['_tcl';'helpers';'lsort'], 'ascii'
20 sort = get_root_global ['_tcl';'helpers';'lsort'], 'sort'
23 .local int decr, unique
28 unless argv goto got_list
30 if $P0 == '-decreasing' goto c_decr
31 if $P0 == '-increasing' goto c_incr
32 if $P0 == '-unique' goto c_uniq
33 if $P0 == '-integer' goto c_int
34 if $P0 == '-real' goto c_real
35 if $P0 == '-dictionary' goto c_dict
36 # RT#40749: command etc necessary
40 compare = get_root_global ['_tcl';'helpers';'lsort'], 'dictionary'
43 compare = get_root_global ['_tcl';'helpers';'lsort'], 'real'
55 compare = get_root_global ['_tcl';'helpers';'lsort'], 'integer'
62 __list = get_root_global ['_tcl'], '__list'
67 unless unique goto skip_unique
72 if size == 0 goto strip_end
76 if c == size goto strip_end
80 if $P1 != $P2 goto strip_loop
88 unless decr goto ordered
91 reverse = get_root_global ['_tcl'], 'reverse'
101 $S0 .= '": must be -ascii, -command, -decreasing, -dictionary, -increasing, -index, -indices, -integer, -nocase, -real, or -unique'
104 tcl_error 'wrong # args: should be "lsort ?options? list"'
108 .namespace [ 'helpers'; 'lsort' ]
121 # check that they're actually integers.
122 # This points out that we should really be caching
123 # the integer value rather than recalculating on each compare.
125 __integer = get_root_global ['_tcl'], '__integer'
139 .include 'cclass.pasm'
141 .local int len1, len2, pos1, pos2
147 if pos1 >= len1 goto end1
148 if pos2 >= len2 goto greater
150 $I0 = is_cclass .CCLASS_NUMERIC, s1, pos1
152 $I0 = is_cclass .CCLASS_NUMERIC, s2, pos2
155 .local string char1, char2, sortchar1, sortchar2
156 char1 = substr s1, pos1, 1
157 char2 = substr s2, pos2, 1
158 sortchar1 = downcase char1
159 sortchar2 = downcase char2
160 if sortchar1 != sortchar2 goto got_chars
173 $I3 = find_not_cclass .CCLASS_NUMERIC, s1, pos1, len1
174 if $I3 == pos1 goto greater
176 $I4 = find_not_cclass .CCLASS_NUMERIC, s2, pos2, len2
177 if $I4 == pos2 goto less
181 $S1 = substr s1, pos1, $I5
182 $S2 = substr s2, pos2, $I6
189 if $I1 < $I2 goto less
190 if $I1 > $I2 goto greater
194 if len1 == len2 goto equal
210 # check that they're actually numbers
212 __number = get_root_global ['_tcl'], '__number'
224 # vim: expandtab shiftwidth=4 ft=pir: