mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
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
1 changed files with 5 additions and 1 deletions
|
|
@ -755,7 +755,8 @@ number:
|
|||
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 @@ number:
|
|||
PCHAR('x');
|
||||
}
|
||||
}
|
||||
if (!ladjust && width && (width -= tmp) > 0)
|
||||
while (width--)
|
||||
PCHAR(padc);
|
||||
|
||||
while (*p)
|
||||
PCHAR(*p--);
|
||||
|
|
|
|||
Loading…
Reference in a new issue