FIX printf: '%0(invalid)' as-is (don't exclude '%')

This commit is contained in:
2025-07-24 20:32:49 +02:00
parent 89b50c83ba
commit 7c46988508

View File

@@ -222,6 +222,7 @@ printf:
je .wrapup je .wrapup
cmp byte [rdi + 1], '%' cmp byte [rdi + 1], '%'
je .rep_pct je .rep_pct
xor r12, r12
; Include specifier (r13 bit0=1) or not (bit0=0) ; Include specifier (r13 bit0=1) or not (bit0=0)
xor r13, r13 xor r13, r13
cmp byte [rdi + 1], '#' cmp byte [rdi + 1], '#'
@@ -230,15 +231,13 @@ printf:
bts r13, 0 bts r13, 0
; Padding: zeroes (r13i bit1=1) or spaces (bit1=0) ; Padding: zeroes (r13i bit1=1) or spaces (bit1=0)
.argGetPadZeroes: .argGetPadZeroes:
mov r12, 1
cmp byte [rdi + 1], '0' cmp byte [rdi + 1], '0'
jb .noPadding jb .checkReplArg
ja .padSpaces ja .padSpaces
bts r13, 1 bts r13, 1
.padSpaces: .padSpaces:
cmp byte [rdi + 1], '9' cmp byte [rdi + 1], '9'
jg .noPadding jg .checkReplArg
xor r12, r12
xor rcx, rcx xor rcx, rcx
inc rdi inc rdi
.findPaddingNumLen: .findPaddingNumLen:
@@ -271,7 +270,10 @@ printf:
loop .getPaddingLoop loop .getPaddingLoop
pop rax pop rax
pop rdi pop rdi
.noPadding: test r12, r12
jnz .checkReplArg
dec rdi
.checkReplArg:
cmp byte [rdi + 1], 'c' cmp byte [rdi + 1], 'c'
je .rep_c je .rep_c
cmp byte [rdi + 1], 'i' cmp byte [rdi + 1], 'i'