Fixed "%s" always being left justify (#2331) (#2332)

This commit is contained in:
F1F88 2025-11-09 00:36:01 +08:00 committed by GitHub
parent 2ae0d05a23
commit 74e9cdd709
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -188,6 +188,15 @@ bool AddString(char **buf_p, size_t &maxlen, const char *string, int width, int
width -= size; width -= size;
if (!(flags & LADJUST))
{
while ((width-- > 0) && maxlen)
{
*buf++ = ' ';
maxlen--;
}
}
if (g_FormatEscapeDatabase && (flags & NOESCAPE) == 0) if (g_FormatEscapeDatabase && (flags & NOESCAPE) == 0)
{ {
char *tempBuffer = NULL; char *tempBuffer = NULL;
@ -226,10 +235,13 @@ bool AddString(char **buf_p, size_t &maxlen, const char *string, int width, int
} }
} }
while ((width-- > 0) && maxlen) if (flags & LADJUST)
{ {
*buf++ = ' '; while ((width-- > 0) && maxlen)
maxlen--; {
*buf++ = ' ';
maxlen--;
}
} }
*buf_p = buf; *buf_p = buf;