From: Bruno Haible Date: Thu, 10 Apr 2025 08:42:12 +0000 (+0200) Subject: vasnprintf: Fix handling of # flag in %b, %B directives. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9bdacf26af3e94aa171f23edd5aff8a1906aa981;p=gnulib.git vasnprintf: Fix handling of # flag in %b, %B directives. * lib/vasnprintf.c (VASNPRINTF): In the prec_ourselves code, treat a 0b prefix like a 0x prefix. --- diff --git a/ChangeLog b/ChangeLog index ac2b7b032d..457a00bed8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-04-10 Bruno Haible + + vasnprintf: Fix handling of # flag in %b, %B directives. + * lib/vasnprintf.c (VASNPRINTF): In the prec_ourselves code, treat a 0b + prefix like a 0x prefix. + 2025-04-08 Bruno Haible stddef-h: Make a configure test work with upcoming GCC 15. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 9bdea145d1..9d6b2eab0c 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -6876,10 +6876,13 @@ VASNPRINTF (DCHAR_T *resultbuf, size_t *lengthp, || *prec_ptr == ' ')) prefix_count = 1; /* Put the additional zeroes after the 0x prefix if - (flags & FLAG_ALT) || (dp->conversion == 'p'). */ + (flags & FLAG_ALT) || (dp->conversion == 'p'), or + after the 0b prefix if (flags & FLAG_ALT). */ else if (count >= 2 && prec_ptr[0] == '0' - && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X')) + && (prec_ptr[1] == 'x' || prec_ptr[1] == 'X' + || prec_ptr[1] == 'b' + || prec_ptr[1] == 'B')) prefix_count = 2; move = count - prefix_count;