[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
printf "%010a" Inf/NaN and FreeBSD
From: |
Bruno Haible |
Subject: |
printf "%010a" Inf/NaN and FreeBSD |
Date: |
Thu, 5 Apr 2007 02:28:22 +0200 |
User-agent: |
KMail/1.5.4 |
On FreeBSD 6.1, printf of "%010a" of Infinity and NaN yields
"0000000inf" and "0000000nan", respectively.
While on glibc systems, it yields
" inf" and " nan", respectively.
I find glibc's output more sensible, since strtod will accept it, while
strtod will not grok "0000000inf". But FreeBSD appears to be closer to
the POSIX wording, I won't count it as a FreeBSD bug.
2007-04-04 Bruno Haible <address@hidden>
* tests/test-vasnprintf-posix.c (test_function): Allow two possible
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): Remove these tests.
* tests/test-fprintf-posix.out: Update.
Needed for FreeBSD 6.1.
*** tests/test-vasnprintf-posix.c 25 Mar 2007 19:56:22 -0000 1.4
--- tests/test-vasnprintf-posix.c 5 Apr 2007 00:15:31 -0000
***************
*** 416,422 ****
char *result =
my_asnprintf (NULL, &length, "%010a %d", 1.0 / 0.0, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
--- 416,423 ----
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);
}
***************
*** 426,432 ****
char *result =
my_asnprintf (NULL, &length, "%010a %d", NaN (), 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
--- 427,434 ----
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);
}
***************
*** 724,730 ****
char *result =
my_asnprintf (NULL, &length, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (length == strlen (result));
free (result);
}
--- 726,733 ----
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);
}
***************
*** 734,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);
ASSERT (length == strlen (result));
free (result);
}
--- 737,744 ----
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);
}
*** tests/test-vasprintf-posix.c 27 Mar 2007 20:18:17 -0000 1.4
--- tests/test-vasprintf-posix.c 5 Apr 2007 00:15:31 -0000
***************
*** 397,403 ****
int retval =
my_asprintf (&result, "%010a %d", 1.0 / 0.0, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
--- 397,404 ----
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);
}
***************
*** 407,413 ****
int retval =
my_asprintf (&result, "%010a %d", NaN (), 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
--- 408,415 ----
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);
}
***************
*** 705,711 ****
int retval =
my_asprintf (&result, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
--- 707,714 ----
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);
}
***************
*** 715,721 ****
int retval =
my_asprintf (&result, "%010La %d", 0.0L / 0.0L, 33, 44, 55);
ASSERT (result != NULL);
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
free (result);
}
--- 718,725 ----
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);
}
*** tests/test-snprintf-posix.h 25 Mar 2007 19:56:22 -0000 1.2
--- tests/test-snprintf-posix.h 5 Apr 2007 00:15:31 -0000
***************
*** 341,347 ****
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);
ASSERT (retval == strlen (result));
}
--- 341,348 ----
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));
}
***************
*** 349,355 ****
char result[100];
int retval =
my_snprintf (result, sizeof (result), "%010a %d", NaN (), 33, 44, 55);
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
--- 350,357 ----
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));
}
***************
*** 599,605 ****
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);
ASSERT (retval == strlen (result));
}
--- 601,608 ----
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));
}
***************
*** 607,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);
ASSERT (retval == strlen (result));
}
--- 610,617 ----
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));
}
*** tests/test-sprintf-posix.h 25 Mar 2007 19:56:22 -0000 1.2
--- tests/test-sprintf-posix.h 5 Apr 2007 00:15:31 -0000
***************
*** 327,333 ****
char result[1000];
int retval =
my_sprintf (result, "%010a %d", 1.0 / 0.0, 33, 44, 55);
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
}
--- 327,334 ----
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));
}
***************
*** 335,341 ****
char result[1000];
int retval =
my_sprintf (result, "%010a %d", NaN (), 33, 44, 55);
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
--- 336,343 ----
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));
}
***************
*** 585,591 ****
char result[1000];
int retval =
my_sprintf (result, "%010La %d", 1.0L / 0.0L, 33, 44, 55);
! ASSERT (strcmp (result, " inf 33") == 0);
ASSERT (retval == strlen (result));
}
--- 587,594 ----
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));
}
***************
*** 593,599 ****
char result[1000];
int retval =
my_sprintf (result, "%010La %d", 0.0L / 0.0L, 33, 44, 55);
! ASSERT (strcmp (result, " nan 33") == 0);
ASSERT (retval == strlen (result));
}
--- 596,603 ----
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));
}
*** tests/test-fprintf-posix.h 25 Mar 2007 19:56:22 -0000 1.2
--- tests/test-fprintf-posix.h 5 Apr 2007 00:15:31 -0000
***************
*** 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);
--- 61,66 ----
*** tests/test-fprintf-posix.out 9 Mar 2007 02:43:32 -0000 1.1
--- tests/test-fprintf-posix.out 5 Apr 2007 00:15:31 -0000
***************
*** 6,11 ****
inf 33
-inf 33
nan 33
- inf 33
- nan 33
55 33
--- 6,9 ----