2007-03-25 Bruno Haible <bruno@clisp.org>
+ * tests/test-frexp.c (NaN): New function/macro.
+ (main): Use it instead of 0.0 / 0.0.
+ * tests/test-isnan.c (NaN): New function/macro.
+ (main): Use it instead of 0.0 / 0.0.
+ * tests/test-vasnprintf-posix.c (NaN): New function/macro.
+ (test_function): Use it instead of 0.0 / 0.0.
+ * tests/test-vasprintf-posix.c (NaN): New function/macro.
+ (test_function): Use it instead of 0.0 / 0.0.
+ * tests/test-snprintf-posix.h (NaN): New function/macro.
+ (test_function): Use it instead of 0.0 / 0.0.
+ * tests/test-sprintf-posix.h (NaN): New function/macro.
+ (test_function): Use it instead of 0.0 / 0.0.
+ * tests/test-fprintf-posix.h (NaN): New function/macro.
+ (test_function): Use it instead of 0.0 / 0.0.
+ * tests/test-printf-posix.h (NaN): New function/macro.
+ (test_function): Use it instead of 0.0 / 0.0.
+
* lib/isnan.c (FUNC): Work around a DEC C compiler bug.
2007-03-25 Bruno Haible <bruno@clisp.org>
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+/* 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
+
static void
test_function (int (*my_fprintf) (FILE *, const char *, ...))
{
my_fprintf (stdout, "%a %d\n", -1.0 / 0.0, 33, 44, 55);
/* NaN. */
- my_fprintf (stdout, "%a %d\n", 0.0 / 0.0, 33, 44, 55);
+ my_fprintf (stdout, "%a %d\n", NaN (), 33, 44, 55);
/* FLAG_ZERO with infinite number. */
my_fprintf (stdout, "%010a %d\n", 1.0 / 0.0, 33, 44, 55);
/* FLAG_ZERO with NaN. */
- my_fprintf (stdout, "%010a %d\n", 0.0 / 0.0, 33, 44, 55);
+ my_fprintf (stdout, "%010a %d\n", NaN (), 33, 44, 55);
/* Test the support of the POSIX/XSI format strings with positions. */
#define ASSERT(expr) if (!(expr)) abort ();
+/* 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
+
static double
my_ldexp (double x, int d)
{
{ /* NaN. */
int exp = -9999;
double mantissa;
- x = 0.0 / 0.0;
+ x = NaN ();
mantissa = frexp (x, &exp);
ASSERT (mantissa != mantissa);
}
#define ASSERT(expr) if (!(expr)) abort ();
+/* 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
+
int
main ()
{
ASSERT (!isnan (1.0 / 0.0));
ASSERT (!isnan (-1.0 / 0.0));
/* Quiet NaN. */
- ASSERT (isnan (0.0 / 0.0));
+ ASSERT (isnan (NaN ()));
#if defined DBL_EXPBIT0_WORD && defined DBL_EXPBIT0_BIT
/* Signalling NaN. */
{
((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
typedef union { double value; unsigned int word[NWORDS]; } memory_double;
memory_double m;
- m.value = 0.0 / 0.0;
+ m.value = NaN ();
# if DBL_EXPBIT0_BIT > 0
m.word[DBL_EXPBIT0_WORD] ^= (unsigned int) 1 << (DBL_EXPBIT0_BIT - 1);
# else
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+/* 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
+
static void
test_function (int (*my_printf) (const char *, ...))
{
my_printf ("%a %d\n", -1.0 / 0.0, 33, 44, 55);
/* NaN. */
- my_printf ("%a %d\n", 0.0 / 0.0, 33, 44, 55);
+ my_printf ("%a %d\n", NaN (), 33, 44, 55);
/* FLAG_ZERO with infinite number. */
my_printf ("%010a %d\n", 1.0 / 0.0, 33, 44, 55);
/* FLAG_ZERO with NaN. */
- my_printf ("%010a %d\n", 0.0 / 0.0, 33, 44, 55);
+ my_printf ("%010a %d\n", NaN (), 33, 44, 55);
/* Test the support of the POSIX/XSI format strings with positions. */
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+/* 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
+
static void
test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
{
{ /* NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%a %d", 0.0 / 0.0, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%a %d", NaN (), 33, 44, 55);
ASSERT (strcmp (result, "nan 33") == 0);
ASSERT (retval == strlen (result));
}
{ /* FLAG_ZERO with NaN. */
char result[100];
int retval =
- my_snprintf (result, sizeof (result), "%010a %d", 0.0 / 0.0, 33, 44, 55);
+ my_snprintf (result, sizeof (result), "%010a %d", NaN (), 33, 44, 55);
ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
/* Written by Bruno Haible <bruno@clisp.org>, 2007. */
+/* 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
+
static void
test_function (int (*my_sprintf) (char *, const char *, ...))
{
{ /* NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%a %d", 0.0 / 0.0, 33, 44, 55);
+ my_sprintf (result, "%a %d", NaN (), 33, 44, 55);
ASSERT (strcmp (result, "nan 33") == 0);
ASSERT (retval == strlen (result));
}
{ /* FLAG_ZERO with NaN. */
char result[1000];
int retval =
- my_sprintf (result, "%010a %d", 0.0 / 0.0, 33, 44, 55);
+ my_sprintf (result, "%010a %d", NaN (), 33, 44, 55);
ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
#define ASSERT(expr) if (!(expr)) abort ();
+/* 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
+
static void
test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
{ /* NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%a %d", 0.0 / 0.0, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%a %d", NaN (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strcmp (result, "nan 33") == 0);
ASSERT (length == strlen (result));
{ /* FLAG_ZERO with NaN. */
size_t length;
char *result =
- my_asnprintf (NULL, &length, "%010a %d", 0.0 / 0.0, 33, 44, 55);
+ my_asnprintf (NULL, &length, "%010a %d", NaN (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (length == strlen (result));
#define ASSERT(expr) if (!(expr)) abort ();
+/* 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
+
static void
test_function (int (*my_asprintf) (char **, const char *, ...))
{
{ /* NaN. */
char *result;
int retval =
- my_asprintf (&result, "%a %d", 0.0 / 0.0, 33, 44, 55);
+ my_asprintf (&result, "%a %d", NaN (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strcmp (result, "nan 33") == 0);
ASSERT (retval == strlen (result));
{ /* FLAG_ZERO with NaN. */
char *result;
int retval =
- my_asprintf (&result, "%010a %d", 0.0 / 0.0, 33, 44, 55);
+ my_asprintf (&result, "%010a %d", NaN (), 33, 44, 55);
ASSERT (result != NULL);
ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));