From 74e9cdd709152dcd9dd9adc5e4e7d3f231ad16e2 Mon Sep 17 00:00:00 2001 From: F1F88 <0xf1f88@gmail.com> Date: Sun, 9 Nov 2025 00:36:01 +0800 Subject: [PATCH] Fixed "%s" always being left justify (#2331) (#2332) --- core/logic/sprintf.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/core/logic/sprintf.cpp b/core/logic/sprintf.cpp index 703ee4b66..de0dd87f6 100644 --- a/core/logic/sprintf.cpp +++ b/core/logic/sprintf.cpp @@ -188,6 +188,15 @@ bool AddString(char **buf_p, size_t &maxlen, const char *string, int width, int width -= size; + if (!(flags & LADJUST)) + { + while ((width-- > 0) && maxlen) + { + *buf++ = ' '; + maxlen--; + } + } + if (g_FormatEscapeDatabase && (flags & NOESCAPE) == 0) { 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++ = ' '; - maxlen--; + while ((width-- > 0) && maxlen) + { + *buf++ = ' '; + maxlen--; + } } *buf_p = buf;