*printf: Detect large precisions bug on Solaris 10/SPARC.
authorBruno Haible <bruno@clisp.org>
Fri, 24 Dec 2010 09:13:43 +0000 (10:13 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 24 Dec 2010 09:13:43 +0000 (10:13 +0100)
* m4/printf.m4 (gl_PRINTF_PRECISION): Add one more test code, provided
by Paul Eggert.
* tests/test-snprintf-posix.h (test_function): Add this test code here
too.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-vasnprintf-posix.c (test_function): Likewise.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* doc/posix-functions/fprintf.texi: Mention Solaris 10 bug as worked
around by gnulib.
* doc/posix-functions/printf.texi: Likewise.
* doc/posix-functions/snprintf.texi: Likewise.
* doc/posix-functions/sprintf.texi: Likewise.
* doc/posix-functions/vfprintf.texi: Likewise.
* doc/posix-functions/vprintf.texi: Likewise.
* doc/posix-functions/vsnprintf.texi: Likewise.
* doc/posix-functions/vsprintf.texi: Likewise.
* doc/posix-functions/dprintf.texi: Undo last commit.
* doc/posix-functions/vdprintf.texi: Likewise.

16 files changed:
ChangeLog
doc/posix-functions/dprintf.texi
doc/posix-functions/fprintf.texi
doc/posix-functions/printf.texi
doc/posix-functions/snprintf.texi
doc/posix-functions/sprintf.texi
doc/posix-functions/vdprintf.texi
doc/posix-functions/vfprintf.texi
doc/posix-functions/vprintf.texi
doc/posix-functions/vsnprintf.texi
doc/posix-functions/vsprintf.texi
m4/printf.m4
tests/test-snprintf-posix.h
tests/test-sprintf-posix.h
tests/test-vasnprintf-posix.c
tests/test-vasprintf-posix.c

index 97909feba960dab60d9c1ef5012847175b3b8e18..038e38bbccb38f1abafaf86803d62232c31fe833 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2010-12-24  Bruno Haible  <bruno@clisp.org>
+
+       *printf: Detect large precisions bug on Solaris 10/SPARC.
+       * m4/printf.m4 (gl_PRINTF_PRECISION): Add one more test code, provided
+       by Paul Eggert.
+       * tests/test-snprintf-posix.h (test_function): Add this test code here
+       too.
+       * tests/test-sprintf-posix.h (test_function): Likewise.
+       * tests/test-vasnprintf-posix.c (test_function): Likewise.
+       * tests/test-vasprintf-posix.c (test_function): Likewise.
+       * doc/posix-functions/fprintf.texi: Mention Solaris 10 bug as worked
+       around by gnulib.
+       * doc/posix-functions/printf.texi: Likewise.
+       * doc/posix-functions/snprintf.texi: Likewise.
+       * doc/posix-functions/sprintf.texi: Likewise.
+       * doc/posix-functions/vfprintf.texi: Likewise.
+       * doc/posix-functions/vprintf.texi: Likewise.
+       * doc/posix-functions/vsnprintf.texi: Likewise.
+       * doc/posix-functions/vsprintf.texi: Likewise.
+       * doc/posix-functions/dprintf.texi: Undo last commit.
+       * doc/posix-functions/vdprintf.texi: Likewise.
+
 2010-12-23  Paul Eggert  <eggert@cs.ucla.edu>
 
        tests: port test-fdutimensat.c to Solaris 8
index 3f9f54b624d968c8d66f44363208c34298b37604..dc39022926097cbb2c4816b50c1632ef4927d189 100644 (file)
@@ -24,9 +24,4 @@ glibc-2.3.6.
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index 116d20e13f94e333d78a5769360cf1669cd346fe..e922e85e08cd9ea4c603ae621eba041ab243afc2 100644 (file)
@@ -55,6 +55,11 @@ This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, BeOS.
 @item
+This function mishandles large floating point precisions
+(for example, formatting 1.0 with @samp{"%.511f"})
+on some platforms:
+Solaris 10.
+@item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 @end itemize
@@ -69,9 +74,4 @@ mingw.
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index fb894d6f45dab5ce45cef2b1dc4b71aaa56c9dbe..eaee96a753c047cbb25e500ff4ca5e586b7a179f 100644 (file)
@@ -55,6 +55,11 @@ This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, BeOS.
 @item
+This function mishandles large floating point precisions
+(for example, formatting 1.0 with @samp{"%.511f"})
+on some platforms:
+Solaris 10.
+@item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 @end itemize
@@ -69,9 +74,4 @@ mingw.
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index 5d19ccf117cd363ce23aad5f0b7fdc9d90c2145c..aa3280862e7985afe423ce58e67ae1a5de97ea5e 100644 (file)
@@ -69,6 +69,11 @@ This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, BeOS.
 @item
+This function mishandles large floating point precisions
+(for example, formatting 1.0 with @samp{"%.511f"})
+on some platforms:
+Solaris 10.
+@item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 @item
@@ -89,9 +94,4 @@ OSF/1 5.1.
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index cce9627625fffc1f6de8e5730a6d55a19c475124..ad6671f6ba4a5ceac8c388748503ef57fa1d7226 100644 (file)
@@ -55,15 +55,15 @@ This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, BeOS.
 @item
+This function mishandles large floating point precisions
+(for example, formatting 1.0 with @samp{"%.511f"})
+on some platforms:
+Solaris 10.
+@item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index 3fa9b737a96267455950d81fe3a9c9cb9ea2fdda..20a6ef75c550101be89f2f682c26cfa54e7aa559 100644 (file)
@@ -42,9 +42,4 @@ BeOS.
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index 7f41c0d5522ab74e958a8ca264631fa19545a613..7e502347de560987645a6682e0eb65cac347366c 100644 (file)
@@ -55,6 +55,11 @@ This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, BeOS.
 @item
+This function mishandles large floating point precisions
+(for example, formatting 1.0 with @samp{"%.511f"})
+on some platforms:
+Solaris 10.
+@item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 @end itemize
@@ -69,9 +74,4 @@ mingw.
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index 213461c9f36301bdef7b32c5405501c2aaa1b8e8..526070e22d981670bac3d85a8f8a410cd2ccc17b 100644 (file)
@@ -55,6 +55,11 @@ This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, BeOS.
 @item
+This function mishandles large floating point precisions
+(for example, formatting 1.0 with @samp{"%.511f"})
+on some platforms:
+Solaris 10.
+@item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 @end itemize
@@ -69,9 +74,4 @@ mingw.
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index 38266a01eec36aa0393bbbdcc8da72bf4815a4de..2ea98cbb978c9a773c74241a287ea021c3ad9daf 100644 (file)
@@ -69,6 +69,11 @@ This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, BeOS.
 @item
+This function mishandles large floating point precisions
+(for example, formatting 1.0 with @samp{"%.511f"})
+on some platforms:
+Solaris 10.
+@item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 @item
@@ -89,9 +94,4 @@ HP-UX 11, OSF/1 5.1.
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index 317853885a45c632935eba9e39c3dfb02653fd30..39203d0d33f002f56584dd706dd82580c5203c39 100644 (file)
@@ -55,15 +55,15 @@ This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
 Solaris 10/x86, mingw, BeOS.
 @item
+This function mishandles large floating point precisions
+(for example, formatting 1.0 with @samp{"%.511f"})
+on some platforms:
+Solaris 10.
+@item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
 @end itemize
 
 Portability problems not fixed by Gnulib:
 @itemize
-@item
-This function mishandles large floating point precisions
-(for example, formatting 1.0 with @samp{"%.511f"})
-on some platforms:
-Solaris 10.
 @end itemize
index 8cffa6ad255d7f4883be7b02ef960b7d312cc6e7..6c8a7a45bfb72c437da41e501a03fb23ca358360 100644 (file)
@@ -1,4 +1,4 @@
-# printf.m4 serial 41
+# printf.m4 serial 42
 dnl Copyright (C) 2003, 2007-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -890,8 +890,9 @@ changequote([,])dnl
 dnl Test whether the *printf family of functions supports large precisions.
 dnl On mingw, precisions larger than 512 are treated like 512, in integer,
 dnl floating-point or pointer output. On Solaris 10/x86, precisions larger
-dnl than 510 in floating-point output crash the program. On BeOS, precisions
-dnl larger than 1044 crash the program.
+dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC,
+dnl precisions larger than 510 in floating-point output yield wrong results.
+dnl On BeOS, precisions larger than 1044 crash the program.
 dnl Result is gl_cv_func_printf_precision.
 
 AC_DEFUN([gl_PRINTF_PRECISION],
@@ -917,6 +918,9 @@ int main ()
     result |= 1;
   if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
     result |= 2;
+  if (sprintf (buf, "%.511f %d", 1.0, 33, 44) < 511 + 5
+      || buf[0] != '1')
+    result |= 4;
   return result;
 }]])],
         [gl_cv_func_printf_precision=yes],
@@ -1459,7 +1463,7 @@ dnl   Cygwin 1.5.25 (2008)           .  .  .  #  #  .  .  #  .  .  .  .  .  #  .
 dnl   Cygwin 1.5.19 (2006)           #  .  .  #  #  #  .  #  .  #  .  #  #  #  .  .  .  .  .  .
 dnl   Solaris 11 2010-11             .  .  #  #  #  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .
 dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  #  .  .  .  .  .  .  .
-dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  #  .  .  .  #  .  .  .  .  #  .  .  .
+dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  #  .  .  .  #  #  .  .  .  #  .  .  .
 dnl   Solaris 2.5.1                  #  .  #  #  #  #  .  #  .  .  .  #  .  .  #  #  #  #  #  #
 dnl   AIX 5.2, 7.1                   .  .  #  #  #  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .
 dnl   AIX 4.3.2, 5.1                 #  .  #  #  #  #  .  .  .  .  .  #  .  .  .  .  #  .  .  .
index 37612f9ef44c716a899ec6befba6a975a60c2df5..b2a0ebef984bdaee841d5eacae1c3d2ce90012e3 100644 (file)
@@ -3044,6 +3044,19 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
     ASSERT (retval == strlen (result));
   }
 
+  {
+    char result[1000];
+    int retval =
+      my_snprintf (result, sizeof (result), "%.511f %d", 1.0, 99);
+    size_t i;
+    ASSERT (result[0] == '1');
+    ASSERT (result[1] == '.');
+    for (i = 0; i < 511; i++)
+      ASSERT (result[2 + i] == '0');
+    ASSERT (strcmp (result + 2 + 511, " 99") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
   {
     char input[5000];
     char result[5000];
index ff162aa87728622959df11a1b4b9522e86d49c56..35451da50d271c701c4d48609274cfbbb63d030d 100644 (file)
@@ -3030,6 +3030,19 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
     ASSERT (retval == strlen (result));
   }
 
+  {
+    char result[1000];
+    int retval =
+      my_sprintf (result, "%.511f %d", 1.0, 99);
+    size_t i;
+    ASSERT (result[0] == '1');
+    ASSERT (result[1] == '.');
+    for (i = 0; i < 511; i++)
+      ASSERT (result[2 + i] == '0');
+    ASSERT (strcmp (result + 2 + 511, " 99") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
   {
     char input[5000];
     char result[5000];
index dd98691ad0da9f32f15e8f01056c7dcde7ef7c4e..44f262fdcadf6d8a9784341face972352968bad5 100644 (file)
@@ -3567,6 +3567,21 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
     free (result);
   }
 
+  {
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%.511f %d", 1.0, 99);
+    size_t i;
+    ASSERT (result != NULL);
+    ASSERT (result[0] == '1');
+    ASSERT (result[1] == '.');
+    for (i = 0; i < 511; i++)
+      ASSERT (result[2 + i] == '0');
+    ASSERT (strcmp (result + 2 + 511, " 99") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
   {
     char input[5000];
     size_t length;
index 8f71c4f974ae35ab98abce560aea7a17917f40c8..5b586ad7e785784da0d9dc3af700fe93a9c21c7a 100644 (file)
@@ -3547,6 +3547,21 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     free (result);
   }
 
+  {
+    char *result;
+    int retval =
+      my_asprintf (&result, "%.511f %d", 1.0, 99);
+    size_t i;
+    ASSERT (result != NULL);
+    ASSERT (result[0] == '1');
+    ASSERT (result[1] == '.');
+    for (i = 0; i < 511; i++)
+      ASSERT (result[2 + i] == '0');
+    ASSERT (strcmp (result + 2 + 511, " 99") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
   {
     char input[5000];
     char *result;