summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-03-17 22:33:24 +0100
committerBruno Haible <bruno@clisp.org>2023-03-17 22:33:24 +0100
commit21ed6e8365e371b9088df727d0449133df58e9bc (patch)
treeb039325d0b43e13e5681e3086b85b05d59d9b8fb /lib
parentfa7279f31f55813cc82766213ee415ef11c83f90 (diff)
downloadgnulib-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.
Diffstat (limited to 'lib')
-rw-r--r--lib/vasnprintf.c10
1 files changed, 5 insertions, 5 deletions
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;