mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-06 18:08:36 +00:00
Fixed when the int value of "%0[width]d" is negative, the minus sign should be formatted before the padding '0' (#2329)
This commit is contained in:
parent
22cc68808c
commit
2ae0d05a23
@ -491,13 +491,15 @@ void AddInt(char **buf_p, size_t &maxlen, int val, int width, int flags)
|
||||
unsignedVal /= 10;
|
||||
} while (unsignedVal);
|
||||
|
||||
if (signedVal < 0)
|
||||
{
|
||||
text[digits++] = '-';
|
||||
}
|
||||
|
||||
buf = *buf_p;
|
||||
|
||||
// minus sign BEFORE left padding if padding with zeros
|
||||
if (signedVal < 0 && maxlen && (flags & ZEROPAD))
|
||||
{
|
||||
*buf++ = '-';
|
||||
maxlen--;
|
||||
}
|
||||
|
||||
if (!(flags & LADJUST))
|
||||
{
|
||||
while ((digits < width) && maxlen)
|
||||
@ -508,6 +510,13 @@ void AddInt(char **buf_p, size_t &maxlen, int val, int width, int flags)
|
||||
}
|
||||
}
|
||||
|
||||
// minus sign AFTER left padding if padding with spaces
|
||||
if (signedVal < 0 && maxlen && !(flags & ZEROPAD))
|
||||
{
|
||||
*buf++ = '-';
|
||||
maxlen--;
|
||||
}
|
||||
|
||||
while (digits-- && maxlen)
|
||||
{
|
||||
*buf++ = text[digits];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user