[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf "%010a" Inf/NaN and FreeBSD
From: |
Bruno Haible |
Subject: |
Re: printf "%010a" Inf/NaN and FreeBSD |
Date: |
Wed, 11 Apr 2007 02:25:02 +0200 |
User-agent: |
KMail/1.5.4 |
Eric Blake wrote:
> FreeBSD 6.1 is buggy. Can we please revert this patch, and instead catch the
> FreeBSD bug during ./configure?
Done. See patch below.
With this, two bugs are still remaining in *printf that are not yet worked
around:
- printf of "%010f" of NaN and Infinity on FreeBSD,
- printf of 'long double' numbers on mingw is unsupported, reported in
http://www.trnicely.net/misc/vista.html
2007-04-10 Bruno Haible <address@hidden>
* m4/printf.m4 (gl_PRINTF_DIRECTIVE_A): Add a test for correct result
for NaN and Infinity. Needed on FreeBSD 6.1.
* tests/test-vasnprintf-posix.c (test_function): Undo last change
regarding results for "%010a" of Infinity and NaN.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* tests/test-snprintf-posix.h (test_function): Likewise.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-fprintf-posix.h (test_function): Likewise.
* tests/test-printf-posix.h (test_function): Likewise.
* tests/test-fprintf-posix.out: Likewise.
*** m4/printf.m4 6 Apr 2007 14:36:56 -0000 1.14
--- m4/printf.m4 11 Apr 2007 00:19:43 -0000
***************
*** 1,4 ****
! # printf.m4 serial 4
dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
--- 1,4 ----
! # printf.m4 serial 5
dnl Copyright (C) 2003, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 118,123 ****
--- 118,128 ----
&& strcmp (result, "0x6.0ap-2 33") != 0
&& strcmp (result, "0xc.14p-3 33") != 0))
return 1;
+ /* This catches a FreeBSD 6.1 bug. See
+ <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
+ if (sprintf (buf, "%010a %d", 1.0 / 0.0, 33, 44, 55) < 0
+ || result[0] == '0')
+ return 1;
/* This catches a MacOS X 10.3.9 (Darwin 7.9) bug. */
if (sprintf (buf, "%.1a", 1.999) < 0
|| (strcmp (buf, "0x1.0p+1") != 0
*** tests/test-vasnprintf-posix.c 6 Apr 2007 14:36:56 -0000 1.6
--- tests/test-vasnprintf-posix.c 11 Apr 2007 00:19:43 -0000
***************
*** 414,421 ****
char *result =
my_asnprintf (NULL, &length, "%010a %d", 1.0 / 0.0, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " inf 33") == 0
! || strcmp (result, "0000000inf 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
--- 414,422 ----
char *result =
my_asnprintf (NULL, &length, "%010a %d", 1.0 / 0.0, 33, 44, 55);
ASSERT (result != NULL);
! /* "0000000inf 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
***************
*** 425,432 ****
char *result =
my_asnprintf (NULL, &length, "%010a %d", NaN (), 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " nan 33") == 0
! || strcmp (result, "0000000nan 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
--- 426,434 ----
char *result =
my_asnprintf (NULL, &length, "%010a %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> */
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
***************
*** 722,729 ****
char *result =
my_asnprintf (NULL, &length, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " inf 33") == 0
! || strcmp (result, "0000000inf 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
--- 724,732 ----
char *result =
my_asnprintf (NULL, &length, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! /* "0000000inf 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
***************
*** 733,740 ****
char *result =
my_asnprintf (NULL, &length, "%010La %d", 0.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " nan 33") == 0
! || strcmp (result, "0000000nan 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
--- 736,744 ----
char *result =
my_asnprintf (NULL, &length, "%010La %d", 0.0L / 0.0L, 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> */
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
*** tests/test-vasprintf-posix.c 6 Apr 2007 14:36:56 -0000 1.6
--- tests/test-vasprintf-posix.c 11 Apr 2007 00:19:43 -0000
***************
*** 395,402 ****
int retval =
my_asprintf (&result, "%010a %d", 1.0 / 0.0, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " inf 33") == 0
! || strcmp (result, "0000000inf 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
--- 395,403 ----
int retval =
my_asprintf (&result, "%010a %d", 1.0 / 0.0, 33, 44, 55);
ASSERT (result != NULL);
! /* "0000000inf 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
***************
*** 406,413 ****
int retval =
my_asprintf (&result, "%010a %d", NaN (), 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " nan 33") == 0
! || strcmp (result, "0000000nan 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
--- 407,415 ----
int retval =
my_asprintf (&result, "%010a %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> */
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
***************
*** 703,710 ****
int retval =
my_asprintf (&result, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " inf 33") == 0
! || strcmp (result, "0000000inf 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
--- 705,713 ----
int retval =
my_asprintf (&result, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! /* "0000000inf 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
***************
*** 714,721 ****
int retval =
my_asprintf (&result, "%010La %d", 0.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " nan 33") == 0
! || strcmp (result, "0000000nan 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
--- 717,725 ----
int retval =
my_asprintf (&result, "%010La %d", 0.0L / 0.0L, 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> */
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
*** tests/test-snprintf-posix.h 6 Apr 2007 14:36:56 -0000 1.4
--- tests/test-snprintf-posix.h 11 Apr 2007 00:19:43 -0000
***************
*** 339,346 ****
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010a %d", 1.0 / 0.0, 33, 44,
55);
! ASSERT (strcmp (result, " inf 33") == 0
! || strcmp (result, "0000000inf 33") == 0);
ASSERT (retval == strlen (result));
}
--- 339,347 ----
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010a %d", 1.0 / 0.0, 33, 44,
55);
! /* "0000000inf 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
}
***************
*** 348,355 ****
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010a %d", NaN (), 33, 44, 55);
! ASSERT (strcmp (result, " nan 33") == 0
! || strcmp (result, "0000000nan 33") == 0);
ASSERT (retval == strlen (result));
}
--- 349,357 ----
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010a %d", NaN (), 33, 44, 55);
! /* "0000000nan 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
***************
*** 597,604 ****
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010La %d", 1.0L / 0.0L, 33, 44,
55);
! ASSERT (strcmp (result, " inf 33") == 0
! || strcmp (result, "0000000inf 33") == 0);
ASSERT (retval == strlen (result));
}
--- 599,607 ----
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010La %d", 1.0L / 0.0L, 33, 44,
55);
! /* "0000000inf 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
}
***************
*** 606,613 ****
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010La %d", 0.0L / 0.0L, 33, 44,
55);
! ASSERT (strcmp (result, " nan 33") == 0
! || strcmp (result, "0000000nan 33") == 0);
ASSERT (retval == strlen (result));
}
--- 609,617 ----
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010La %d", 0.0L / 0.0L, 33, 44,
55);
! /* "0000000nan 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
*** tests/test-sprintf-posix.h 6 Apr 2007 14:36:56 -0000 1.4
--- tests/test-sprintf-posix.h 11 Apr 2007 00:19:43 -0000
***************
*** 325,332 ****
char result[1000];
int retval =
my_sprintf (result, "%010a %d", 1.0 / 0.0, 33, 44, 55);
! ASSERT (strcmp (result, " inf 33") == 0
! || strcmp (result, "0000000inf 33") == 0);
ASSERT (retval == strlen (result));
}
--- 325,333 ----
char result[1000];
int retval =
my_sprintf (result, "%010a %d", 1.0 / 0.0, 33, 44, 55);
! /* "0000000inf 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
}
***************
*** 334,341 ****
char result[1000];
int retval =
my_sprintf (result, "%010a %d", NaN (), 33, 44, 55);
! ASSERT (strcmp (result, " nan 33") == 0
! || strcmp (result, "0000000nan 33") == 0);
ASSERT (retval == strlen (result));
}
--- 335,343 ----
char result[1000];
int retval =
my_sprintf (result, "%010a %d", NaN (), 33, 44, 55);
! /* "0000000nan 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
***************
*** 583,590 ****
char result[1000];
int retval =
my_sprintf (result, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
! ASSERT (strcmp (result, " inf 33") == 0
! || strcmp (result, "0000000inf 33") == 0);
ASSERT (retval == strlen (result));
}
--- 585,593 ----
char result[1000];
int retval =
my_sprintf (result, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
! /* "0000000inf 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
}
***************
*** 592,599 ****
char result[1000];
int retval =
my_sprintf (result, "%010La %d", 0.0L / 0.0L, 33, 44, 55);
! ASSERT (strcmp (result, " nan 33") == 0
! || strcmp (result, "0000000nan 33") == 0);
ASSERT (retval == strlen (result));
}
--- 595,603 ----
char result[1000];
int retval =
my_sprintf (result, "%010La %d", 0.0L / 0.0L, 33, 44, 55);
! /* "0000000nan 33" is not a valid result; see
! <http://lists.gnu.org/archive/html/bug-gnulib/2007-04/msg00107.html> */
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
*** tests/test-fprintf-posix.h 5 Apr 2007 00:27:45 -0000 1.3
--- tests/test-fprintf-posix.h 11 Apr 2007 00:19:43 -0000
***************
*** 61,66 ****
--- 61,72 ----
/* NaN. */
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", NaN (), 33, 44, 55);
+
/* Test the support of the POSIX/XSI format strings with positions. */
my_fprintf (stdout, "%2$d %1$d\n", 33, 55);
*** tests/test-fprintf-posix.out 5 Apr 2007 00:27:45 -0000 1.2
--- tests/test-fprintf-posix.out 11 Apr 2007 00:19:43 -0000
***************
*** 6,9 ****
--- 6,11 ----
inf 33
-inf 33
nan 33
+ inf 33
+ nan 33
55 33