From: Bruno Haible Date: Sat, 28 Jan 2023 18:39:23 +0000 (+0100) Subject: unistdio/*printf: Fix negative width handling for %U, %lU, %llU. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ffa1d09d4774b460bdcde5af5be8b3b30bfe5d29;p=gnulib.git unistdio/*printf: Fix negative width handling for %U, %lU, %llU. * lib/vasnprintf.c (VASNPRINTF): In the code for %U, %lU, %llU, test for the FLAG_LEFT bit in the flags variable. --- diff --git a/ChangeLog b/ChangeLog index 622e4f7ffd..4c8197821e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-01-28 Bruno Haible + + unistdio/*printf: Fix negative width handling for %U, %lU, %llU. + * lib/vasnprintf.c (VASNPRINTF): In the code for %U, %lU, %llU, test for + the FLAG_LEFT bit in the flags variable. + 2023-01-28 Bruno Haible vasnprintf-posix: Fix possible bug with negative width handling for %lc. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 0e6220ae18..72b8cdbfa6 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -2130,7 +2130,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (characters < width && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2175,7 +2175,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (characters < width && (dp->flags & FLAG_LEFT)) + if (characters < width && (flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2232,7 +2232,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (characters < width && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2277,7 +2277,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (characters < width && (dp->flags & FLAG_LEFT)) + if (characters < width && (flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2334,7 +2334,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, characters = 0; } - if (characters < width && !(dp->flags & FLAG_LEFT)) + if (characters < width && !(flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n)); @@ -2379,7 +2379,7 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, } # endif - if (characters < width && (dp->flags & FLAG_LEFT)) + if (characters < width && (flags & FLAG_LEFT)) { size_t n = width - characters; ENSURE_ALLOCATION (xsum (length, n));