Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 519 → Rev 518

/kernel/trunk/core/string.inc
File deleted
/kernel/trunk/core/taskman.inc
76,6 → 76,7
 
pushad
 
mov [cmdline], ebx
mov [flags], edx
 
; [ebp] pointer to filename
83,16 → 84,12
lea eax, [filename]
mov dword [eax+1020],0 ;force terminate
;string
stdcall strncpy, eax, [ebp], 1023
stdcall k_strncpy, eax, [ebp], 1023
 
mov [cmdline], ebx
test ebx, ebx
jz @F
 
lea eax, [cmdline]
mov dword [eax+252], 0
stdcall strncpy, eax, ebx, 255
@@:
stdcall k_strncpy, eax, [cmdline], 255
 
lea eax, [filename]
stdcall load_file, eax
mov ecx, -ERROR_FILE_NOT_FOUND
139,8 → 136,9
_clear_ 256 ;clean extended information about process
 
; write application name
lea eax, [filename]
stdcall strrchr, eax, '/' ; now eax points to name without path
lea edi, [filename]
mov al, '/'
call k_strrchr ; now eax points to name without path
 
lea esi, [eax+1]
test eax, eax
965,7 → 963,7
.add_command_line:
mov edx,[params]
mov edx,[edx] ;app_cmdline
test edx, [cmd_line] ;check both src & dst
test edx,edx
jz @F ;application don't need parameters
 
mov eax, edx
975,7 → 973,7
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
ja @f
 
stdcall strncpy, edx, [cmd_line], 256
stdcall k_strncpy, edx, [cmd_line], 256
@@:
mov edx,[params]
mov edx, [edx+4] ;app_path
986,7 → 984,7
jc @f
cmp eax, [SLOT_BASE+APPDATA.mem_size+ebx*8]
ja @f
stdcall strncpy, edx, [app_path], 1024
stdcall k_strncpy, edx, [app_path], 1024
@@:
mov ebx,[slot]
mov eax,ebx
/kernel/trunk/core/memory.inc
1057,7 → 1057,42
endp
 
 
align 4
proc strncmp stdcall, str1:dword, str2:dword, count:dword
 
mov ecx,[count]
jecxz .end
 
mov ebx,ecx
 
mov edi,[str1]
mov esi,edi
xor eax,eax
repne scasb
neg ecx ; cx = count - strlen
add ecx,ebx ; strlen + count - strlen
 
.okay:
mov edi,esi
mov esi,[str2]
repe cmpsb
mov al,[esi-1]
xor ecx,ecx
 
cmp al,[edi-1]
ja .str2_big
je .end
 
.str1_big:
sub ecx,2
 
.str2_big:
not ecx
.end:
mov eax,ecx
ret
endp
 
align 4
proc stall stdcall, delay:dword
push ecx
1085,8 → 1120,227
ret
endp
 
align 4
k_strrchr:
push eax
xor eax,eax
or ecx,-1
repne scasb
add ecx,1
neg ecx
sub edi,1
pop eax
std
repne scasb
cld
add edi,1
 
cmp [edi],al
jne @F
mov eax,edi
ret
@@:
xor eax,eax
ret
 
align 4
proc k_strncpy stdcall, dest:dword, src:dword, maxlen:dword
mov eax, [dest]
mov esi, [src]
mov ecx, [maxlen]
test eax, eax
jz .L9
test esi, esi
jz .L9
test ecx, ecx
jz .L9
 
sub esi, eax
jmp .L1
 
align 4
.L2:
mov edx, [esi+eax]
mov [eax], dl
test dl, dl
jz .L7
 
mov [eax+1], dh
test dh, dh
jz .L6
 
shr edx, 16
mov [eax+2],dl
test dl, dl
jz .L5
 
mov [eax+3], dh
test dh, dh
jz .L4
add eax, 4
.L1:
sub ecx, 4
jae .L2
 
add ecx, 4
jz .L9
 
mov dl, [eax+esi]
mov [eax], dl
test dl, dl
jz .L3
 
inc eax
dec ecx
jz .L9
 
mov dl, [eax+esi]
mov [eax], dl
test dl, dl
jz .L3
 
inc eax
dec ecx
jz .L9
 
mov dl, [eax+esi]
mov [eax], dl
test dl, dl
jz .L3
 
inc eax
jmp .L9
 
.L4: dec ecx
inc eax
 
.L5: dec ecx
inc eax
 
.L6: dec ecx
inc eax
.L7:
add ecx,3
jz .L9
.L8:
mov byte [ecx+eax], 0
.L3:
dec ecx
jnz .L8
.L9:
ret
endp
 
if 0
 
magic equ 0xfefefeff
 
k_strlen:
mov eax,[esp+4]
mov edx, 3
 
and edx, eax
jz .L1
jp .L0
 
cmp dh, byte [eax]
je .L2
 
inc eax
cmp dh, byte [eax]
 
je .L2
 
inc eax
xor edx, 2
 
jz .L1
.L0:
cmp dh, [eax]
je .L2
 
inc eax
xor edx, edx
 
.L1:
mov ecx, [eax]
add eax, 4
 
sub edx, ecx
add ecx, magic
 
dec edx
jnc .L3
 
xor edx, ecx
and edx, not magic
jne .L3
 
mov ecx, [eax]
add eax, 4
 
sub edx, ecx
add ecx, magic
dec edx
jnc .L3
 
xor edx, ecx
and edx, not magic
jne .L3
 
mov ecx, [eax]
add eax, 4
 
sub edx, ecx
add ecx, magic
 
dec edx
jnc .L3
 
xor edx, ecx
 
and edx, not magic
jne .L3
 
mov ecx, [eax]
add eax, 4
 
sub edx, ecx
add ecx, magic
 
dec edx
jnc .L3
 
xor edx, ecx
 
and edx, not magic
je .L1
 
.L3: sub eax ,4
sub ecx, magic
 
cmp cl, 0
jz .L2
 
inc eax
test ch, ch
jz .L2
 
shr ecx, 16
inc eax
 
cmp cl,0
jz .L2
 
inc eax
 
.L2:
sub eax, [esp+4]
ret
 
end if
 
if 0
push eax
push edx
mov edx, 0x400 ;bochs
/kernel/trunk/core/ext_lib.inc
228,7 → 228,7
mov edx,[exp]
.next: test edx,edx
jz .end
stdcall strncmp,[edx],[sz_name], dword -1
stdcall strcmp,[edx],[sz_name]
test eax,eax
jz .ok
add edx,8
306,4 → 306,21
ret
endp
 
proc strcmp, str1:dword,str2:dword
push esi edi
mov esi,[str1]
mov edi,[str2]
xor eax,eax
@@: lodsb
scasb
jne .fail
or al,al
jnz @b
jmp .ok
.fail: or eax,-1
.ok: pop edi esi
ret
endp
 
 
s_libname db 64 dup (0)
/kernel/trunk/core/exports.inc
62,14 → 62,7
szSleep db 'Sleep',0
szGetTimerTicks db 'GetTimerTicks',0
 
szStrncat db 'strncat',0
szStrncpy db 'strncpy',0
szstrncmp db 'strncmp',0
szStrnlen db 'strnlen',0
szStrchr db 'strchr',0
szStrrchr db 'strrchr',0
 
 
align 16
kernel_export:
dd szRegService , reg_service
122,18 → 115,9
dd szSetMouseData , set_mouse_data
dd szSleep , delay_ms
dd szGetTimerTicks , get_timer_ticks
 
dd szStrncat , strncat
dd szStrncpy , strncpy
dd szstrncmp , strncmp
dd szStrnlen , strnlen
dd szStrchr , strchr
dd szStrrchr , strrchr
 
 
exp_lfb:
dd szLFBAddress , 0
dd 0 ;terminator, must be zero
dd 0
 
endg