diff options
author | Bruno Haible <bruno@clisp.org> | 2023-03-17 22:33:24 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2023-03-17 22:33:24 +0100 |
commit | 21ed6e8365e371b9088df727d0449133df58e9bc (patch) | |
tree | b039325d0b43e13e5681e3086b85b05d59d9b8fb | |
parent | fa7279f31f55813cc82766213ee415ef11c83f90 (diff) | |
download | gnulib-21ed6e8365e371b9088df727d0449133df58e9bc.tar.gz |
vasnprintf, vasnwprintf: Simplify code.
* lib/vasnprintf.c (MAX_ROOM_NEEDED): Remove dead code: The directives
'o', 'x', 'X' always take an unsigned integer argument.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/vasnprintf.c | 10 |
2 files changed, 11 insertions, 5 deletions
@@ -1,5 +1,11 @@ 2023-03-17 Bruno Haible <bruno@clisp.org> + vasnprintf, vasnwprintf: Simplify code. + * lib/vasnprintf.c (MAX_ROOM_NEEDED): Remove dead code: The directives + 'o', 'x', 'X' always take an unsigned integer argument. + +2023-03-17 Bruno Haible <bruno@clisp.org> + vasnwprintf: Fix test failure on OpenBSD. * lib/vasnprintf.c (VASNPRINTF): Don't use the %n directive on OpenBSD. diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c index 74a6712926..a49eb1dcd7 100644 --- a/lib/vasnprintf.c +++ b/lib/vasnprintf.c @@ -1654,13 +1654,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, break; case 'o': - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + if (type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.333334 /* binary -> octal */ ) + 1; /* turn floor into ceil */ - else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + else if (type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.333334 /* binary -> octal */ @@ -1679,13 +1679,13 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, break; case 'x': case 'X': - if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT) + if (type == TYPE_ULONGLONGINT) tmp_length = (unsigned int) (sizeof (unsigned long long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ ) + 1; /* turn floor into ceil */ - else if (type == TYPE_LONGINT || type == TYPE_ULONGINT) + else if (type == TYPE_ULONGINT) tmp_length = (unsigned int) (sizeof (unsigned long) * CHAR_BIT * 0.25 /* binary -> hexadecimal */ @@ -1699,7 +1699,7 @@ MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion, + 1; /* turn floor into ceil */ if (tmp_length < precision) tmp_length = precision; - /* Add 2, to account for a leading sign or alternate form. */ + /* Add 2, to account for a prefix from the alternate form. */ tmp_length = xsum (tmp_length, 2); break; |