#include "vasnprintf.h"
#include <float.h>
+#include <math.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
} \
while (0)
-/* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
-#ifdef __DECC
-static double
-NaN ()
-{
- static double zero = 0.0;
- return zero / zero;
-}
-#else
-# define NaN() (0.0 / 0.0)
-#endif
-
/* The SGI MIPS floating-point format does not distinguish 0.0 and -0.0. */
static int
have_minus_zero ()
}
return 0;
}
-
+
static void
test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%a %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%a %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050a %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050a %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
/* "0000000nan 33" is not a valid result; see
<http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%f %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%f %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050f %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050f %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%F %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%F %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 1)
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%e %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%e %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050e %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050e %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%g %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%g %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) >= 3 + 3
&& strisnan (result, 0, strlen (result) - 3, 0)
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%050g %d", NaN (), 33, 44, 55);
+ my_asnprintf (NULL, &length, "%050g %d", NAN, 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strlen (result) == 50 + 3
&& strisnan (result, strspn (result, " "), strlen (result) - 3, 0)