1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-06 03:40:56 -08:00

Simplify new %b/%B code many years from now

* src/editfns.c (styled_format): Do %b and %B with sprintf if
sprintf is known to support them.  This will let us simplify this
code many years from now.  (Bug#79990)
This commit is contained in:
Paul Eggert 2025-12-22 00:10:57 -08:00
parent cff022f0c3
commit 5cf8af2290

View file

@ -4029,7 +4029,19 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
}
p[0] = negative ? '-' : plus_flag ? '+' : ' ';
if (conversion == 'b' || conversion == 'B')
/* Do %b and %B by hand unless sprintf is known to
support them. Some day (the year 2043 perhaps?),
simplify this code by assuming that
HAVE_PRINTF_B_CONVERSION_SPECIFIER is true. */
#if (202311 <= __STDC_VERSION_STDIO_H__ \
|| 2 < __GLIBC__ + (35 <= __GLIBC_MINOR__))
enum { HAVE_PRINTF_B_CONVERSION_SPECIFIER = true };
#else
enum { HAVE_PRINTF_B_CONVERSION_SPECIFIER = false };
#endif
if (!HAVE_PRINTF_B_CONVERSION_SPECIFIER
&& (conversion == 'b' || conversion == 'B'))
{
int bit_width = stdc_bit_width (x);
char *bits = p + negative;