printf: ignore '0' flag if '-' is also used.
This is what the standards require. Previously, the '0' flag would effectively override '-'. Here is a program that demonstrates the problem: #include <stdio.h> int main(void) { printf("|%-020d|\n", 123); printf("|%0-20d|\n", 123); printf("|%0*d|\n", -20, 123); }
This commit is contained in:
parent
bdfed3628d
commit
b7b4182cd2
|
@ -4942,11 +4942,15 @@ Flag lda [format] get the character
|
||||||
bne fl1
|
bne fl1
|
||||||
lda #1 left justify the output
|
lda #1 left justify the output
|
||||||
sta ~leftJustify
|
sta ~leftJustify
|
||||||
|
lda #' ' pad with spaces (ignore any '0' flag)
|
||||||
|
sta ~paddChar
|
||||||
bra fl5
|
bra fl5
|
||||||
|
|
||||||
fl1 cmp #'0' if it is a '0' then
|
fl1 cmp #'0' if it is a '0' then
|
||||||
bne fl2
|
bne fl2
|
||||||
sta ~paddChar padd with '0' characters
|
ldx ~leftJustify if not left justifying then
|
||||||
|
bne fl5
|
||||||
|
sta ~paddChar padd with '0' characters
|
||||||
bra fl5
|
bra fl5
|
||||||
|
|
||||||
fl2 cmp #'+' if it is a '+' or ' ' then
|
fl2 cmp #'+' if it is a '+' or ' ' then
|
||||||
|
@ -4988,6 +4992,8 @@ GetSize stz val assume a value of 0
|
||||||
inc a positive with - flag
|
inc a positive with - flag
|
||||||
ldx #1
|
ldx #1
|
||||||
stx ~leftJustify
|
stx ~leftJustify
|
||||||
|
ldx #' '
|
||||||
|
stx ~paddChar
|
||||||
bra fv1
|
bra fv1
|
||||||
fv0 lda #0 negative precision is ignored
|
fv0 lda #0 negative precision is ignored
|
||||||
stz ~precisionSpecified
|
stz ~precisionSpecified
|
||||||
|
|
Loading…
Reference in New Issue