Better UTF-8 char validation

git-svn-id: svn://kolibrios.org@5921 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pathoswithin 2015-11-19 11:48:55 +00:00
parent b4b39d8387
commit 2f44126352

View File

@ -49,7 +49,7 @@ dtext:
shl ebx, 2 shl ebx, 2
add eax, ebx add eax, ebx
js .ret js .ret
add edi, eax ; linear address (32bit) add edi, eax
mov eax, ecx mov eax, ecx
mov ebx, ecx mov ebx, ecx
test ecx, ecx test ecx, ecx
@ -60,7 +60,7 @@ dtext:
and cl, 7 and cl, 7
inc ecx inc ecx
push ebp ecx esi push ebp ecx esi
mov esi, edx ; -> string mov esi, edx
or eax, 0xFF000000 or eax, 0xFF000000
bt ebx, 27 bt ebx, 27
jc .bufferReady jc .bufferReady
@ -80,9 +80,9 @@ dtext:
mov edx, eax mov edx, eax
mov eax, [esp+24] mov eax, [esp+24]
cmp eax, -1 cmp eax, -1
jnz .background jnz @f
mov [esp+28], edi mov [esp+28], edi
.background: @@:
mov edi, edx mov edi, edx
rep stosd rep stosd
mov edi, edx mov edi, edx
@ -100,6 +100,10 @@ dtext:
bt ebx, 28 bt ebx, 28
jc .drawUTF8 jc .drawUTF8
; ebp = font color
; esi -> string
; edi -> buffer
; Stack map: ; Stack map:
; char counter +0 ; char counter +0
fontMultiplier = 4 fontMultiplier = 4
@ -115,8 +119,7 @@ deltaToScreen = 28
.drawUTF16: .drawUTF16:
dec dword [esp] dec dword [esp]
js .done js .done
xor ebx, ebx movzx ebx, word [esi]
mov bx, [esi]
test ebx, ebx test ebx, ebx
jz .done jz .done
inc esi inc esi
@ -141,27 +144,33 @@ deltaToScreen = 28
dec dword [esp] dec dword [esp]
js .done js .done
@@: @@:
xor ebx, ebx movzx ebx, byte [esi]
mov bl, [esi]
inc esi inc esi
test bl, bl test bl, bl
jz .done jz .done
jns .valid jns .valid
shl bx, 10 shl bx, 10
jnc @b jnc @b
shr bh, 2
mov bl, [esi] mov bl, [esi]
test bl, bl
jns @b
shl bl, 2 shl bl, 2
jc @b
shr bh, 2
shr bx, 2 shr bx, 2
inc esi inc esi
cmp bx, 1419 cmp bx, 1419
jc .valid jc .valid
shl bx, 4 shl bh, 4
@@:
jns @f jns @f
.tail:
mov bl, [esi]
shl bl, 1
jnc @b
js @b
inc esi inc esi
shl bx, 1 shl bh, 1
jmp @b js .tail
@@: @@:
xor ebx, ebx xor ebx, ebx
.valid: .valid:
@ -180,8 +189,7 @@ deltaToScreen = 28
.draw866: .draw866:
dec dword [esp] dec dword [esp]
js .done js .done
xor ebx, ebx movzx ebx, byte [esi]
mov bl, [esi]
test ebx, ebx test ebx, ebx
jz .done jz .done
inc esi inc esi
@ -199,8 +207,7 @@ deltaToScreen = 28
.draw866toUni: .draw866toUni:
dec dword [esp] dec dword [esp]
js .done js .done
xor eax, eax movzx eax, byte [esi]
mov al, [esi]
test eax, eax test eax, eax
jz .done jz .done
call ansi2uni_char call ansi2uni_char
@ -260,6 +267,10 @@ deltaToScreen = 28
; scaling/smoothing algorithm ; scaling/smoothing algorithm
drawChar: drawChar:
; ebp = font color
; esi = font multiplier
; edi -> buffer
; ebx -> char data
mov dl, [ebx] mov dl, [ebx]
.raw: .raw:
bsf eax, edx bsf eax, edx