; Update from Gnulib

This commit is contained in:
Po Lu 2023-06-08 08:48:37 +08:00
parent 59fdd16f90
commit f2b2863ff7
2 changed files with 22 additions and 10 deletions

View file

@ -30,10 +30,6 @@
#include <stdlib.h>
#include <errno.h>
#ifndef SSIZE_MAX
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
# define getc_maybe_unlocked(fp) getc(fp)

View file

@ -927,6 +927,14 @@ divide (mpn_t a, mpn_t b, mpn_t *q)
return roomptr;
}
/* Avoid pointless GCC warning "argument 1 value '18446744073709551615' exceeds
maximum object size 9223372036854775807", triggered by the use of xsum as
argument of malloc. */
# if __GNUC__ >= 7
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Walloc-size-larger-than="
# endif
/* Convert a bignum a >= 0, multiplied with 10^extra_zeroes, to decimal
representation.
Destroys the contents of a.
@ -983,6 +991,10 @@ convert_to_decimal (mpn_t a, size_t extra_zeroes)
return c_ptr;
}
# if __GNUC__ >= 7
# pragma GCC diagnostic pop
# endif
# if NEED_PRINTF_LONG_DOUBLE
/* Assuming x is finite and >= 0:
@ -1177,8 +1189,6 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
void *z_memory;
char *digits;
if (memory == NULL)
return NULL;
/* x = 2^e * m, hence
y = round (2^e * 10^n * m) = round (2^(e+n) * 5^n * m)
= round (2^s * 5^n * m). */
@ -1386,10 +1396,13 @@ scale10_round_decimal_decoded (int e, mpn_t m, void *memory, int n)
static char *
scale10_round_decimal_long_double (long double x, int n)
{
int e IF_LINT(= 0);
int e;
mpn_t m;
void *memory = decode_long_double (x, &e, &m);
return scale10_round_decimal_decoded (e, m, memory, n);
if (memory != NULL)
return scale10_round_decimal_decoded (e, m, memory, n);
else
return NULL;
}
# endif
@ -1404,10 +1417,13 @@ scale10_round_decimal_long_double (long double x, int n)
static char *
scale10_round_decimal_double (double x, int n)
{
int e IF_LINT(= 0);
int e;
mpn_t m;
void *memory = decode_double (x, &e, &m);
return scale10_round_decimal_decoded (e, m, memory, n);
if (memory != NULL)
return scale10_round_decimal_decoded (e, m, memory, n);
else
return NULL;
}
# endif