Skip to content

Commit

Permalink
Fix formatting error when left-aligned and width is less than the num…
Browse files Browse the repository at this point in the history
…ber of characters (#2221) (#2255)
  • Loading branch information
F1F88 authored Feb 4, 2025
1 parent 2a3964a commit b5e077c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/logic/sprintf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ void AddBinary(char **buf_p, size_t &maxlen, unsigned int val, int width, int fl

if (flags & LADJUST)
{
while (width-- && maxlen)
while ((width-- > 0) && maxlen)
{
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
maxlen--;
Expand Down Expand Up @@ -449,7 +449,7 @@ void AddUInt(char **buf_p, size_t &maxlen, unsigned int val, int width, int flag

if (flags & LADJUST)
{
while (width-- && maxlen)
while ((width-- > 0) && maxlen)
{
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
maxlen--;
Expand Down Expand Up @@ -511,7 +511,7 @@ void AddInt(char **buf_p, size_t &maxlen, int val, int width, int flags)

if (flags & LADJUST)
{
while (width-- && maxlen)
while ((width-- > 0) && maxlen)
{
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
maxlen--;
Expand Down Expand Up @@ -572,7 +572,7 @@ void AddHex(char **buf_p, size_t &maxlen, unsigned int val, int width, int flags

if (flags & LADJUST)
{
while (width-- && maxlen)
while ((width-- > 0) && maxlen)
{
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
maxlen--;
Expand Down

0 comments on commit b5e077c

Please sign in to comment.