mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-24 23:56:49 +03:00
@open: add apps sorting; string.inc: add string.cmp for compare strings
git-svn-id: svn://kolibrios.org@5907 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
be110571f5
commit
5ed305bfbd
@ -55,6 +55,29 @@
|
||||
ret
|
||||
endp
|
||||
|
||||
proc string.cmp uses ecx esi edi, _str1, _str2, _n
|
||||
mov ecx, [_n]
|
||||
test ecx, ecx ; Max length is zero?
|
||||
je .done
|
||||
|
||||
mov esi, [_str1] ; esi = string s1
|
||||
mov edi, [_str2] ; edi = string s2
|
||||
cld
|
||||
.compare:
|
||||
cmpsb ; Compare two bytes
|
||||
jne .done
|
||||
cmp byte [esi-1], 0 ; End of string?
|
||||
je .done
|
||||
dec ecx ; Length limit reached?
|
||||
jne .compare
|
||||
.done:
|
||||
seta al ; al = (s1 > s2)
|
||||
setb ah ; ah = (s1 < s2)
|
||||
sub al, ah
|
||||
movsx eax, al ; eax = (s1 > s2) - (s1 < s2), i.e. -1, 0, 1
|
||||
ret
|
||||
endp
|
||||
|
||||
proc string.to_lower_case uses eax, _str
|
||||
mov eax, [_str]
|
||||
@@:
|
||||
|
@ -208,7 +208,6 @@ end if
|
||||
;; if without '.' - execute
|
||||
stdcall string.last_index_of, [param_s], '.', 1
|
||||
cmpe eax, -1, execute
|
||||
|
||||
;; if '.' is part of path - execute
|
||||
mov esi, eax
|
||||
stdcall string.last_index_of, [param_s], '/', 1
|
||||
@ -298,6 +297,7 @@ end if
|
||||
|
||||
;; get list
|
||||
invoke libini.for_each_section, assoc_ini, section_cb
|
||||
stdcall sort_list
|
||||
mov eax, [sb_apps.max_area]
|
||||
and eax, 1b
|
||||
shr [sb_apps.max_area], 1
|
||||
@ -911,6 +911,55 @@ end if
|
||||
|
||||
;----------------------
|
||||
|
||||
proc sort_list
|
||||
mov edi, 0
|
||||
mov ebx, list ;; i = 0
|
||||
imul ecx, [list.size], 32 ;; i < n - 1
|
||||
sub ecx, 32
|
||||
add ecx, list
|
||||
|
||||
.loop1:
|
||||
mov edx, list ;; j = 0
|
||||
mov esi, [list.size] ;; j < n - i - 1
|
||||
sub esi, edi
|
||||
dec esi
|
||||
imul esi, 32
|
||||
add esi, list
|
||||
.loop2:
|
||||
mov eax, edx
|
||||
add eax, 32
|
||||
stdcall string.cmp, edx, eax, 32
|
||||
cmpne eax, 1, .next2
|
||||
;; swap names
|
||||
mov eax, edx
|
||||
add eax, 32
|
||||
stdcall string.copy, edx, buffer7
|
||||
stdcall string.copy, eax, edx
|
||||
stdcall string.copy, buffer7, eax
|
||||
;; swap icons
|
||||
mov eax, edx
|
||||
sub eax, list
|
||||
shr eax, 3
|
||||
add eax, list.icon
|
||||
push ebx ecx
|
||||
mov ebx, [eax]
|
||||
mov ecx, [eax + 4]
|
||||
mov [eax], ecx
|
||||
mov [eax + 4], ebx
|
||||
pop ecx ebx
|
||||
.next2:
|
||||
add edx, 32
|
||||
cmpne edx, esi, .loop2
|
||||
.next1:
|
||||
inc edi
|
||||
add ebx, 32
|
||||
cmpne ebx, ecx, .loop1
|
||||
|
||||
ret
|
||||
endp
|
||||
|
||||
;----------------------
|
||||
|
||||
dataend:
|
||||
|
||||
;===============================
|
||||
@ -932,12 +981,13 @@ end if
|
||||
param_e rd 1
|
||||
param_a rd 1
|
||||
undefined rb 1
|
||||
buffer rb 2048
|
||||
buffer2 rb 2048
|
||||
buffer3 rb 2048
|
||||
buffer4 rb 4096
|
||||
buffer5 rb 4096
|
||||
buffer6 rb 2048
|
||||
buffer rb 2048
|
||||
buffer2 rb 2048 ;OD
|
||||
buffer3 rb 2048 ;OD
|
||||
buffer4 rb 2048 ;OD
|
||||
buffer5 rb 2048 ;OD
|
||||
buffer6 rb 2048 ;check existance
|
||||
buffer7 rb 32 ;for sorting
|
||||
params rb 2048
|
||||
_stack rb 2048
|
||||
memory:
|
||||
|
Loading…
Reference in New Issue
Block a user