When padding with zero, do pad after prefixes rather than padding
before prefixes. Use cases: printf("%05d", -42); --> "00-42" (should be "-0042") printf("%#05x", 12); --> "000xc" (should be "0x00c") Submitted by: Oliver Fromme PR: kern/85520 MFC After: 1 week
This commit is contained in:
parent
245c31ccaf
commit
5248ef8a3c
@ -755,7 +755,8 @@ reswitch: switch (ch = (u_char)*fmt++) {
|
||||
if (neg)
|
||||
tmp++;
|
||||
|
||||
if (!ladjust && width && (width -= tmp) > 0)
|
||||
if (!ladjust && padc != '0' && width
|
||||
&& (width -= tmp) > 0)
|
||||
while (width--)
|
||||
PCHAR(padc);
|
||||
if (neg)
|
||||
@ -768,6 +769,9 @@ reswitch: switch (ch = (u_char)*fmt++) {
|
||||
PCHAR('x');
|
||||
}
|
||||
}
|
||||
if (!ladjust && width && (width -= tmp) > 0)
|
||||
while (width--)
|
||||
PCHAR(padc);
|
||||
|
||||
while (*p)
|
||||
PCHAR(*p--);
|
||||
|
Loading…
Reference in New Issue
Block a user