*printf-posix: Detect a bug on Solaris 10/x86.
authorBruno Haible <bruno@clisp.org>
Sun, 28 Nov 2010 00:23:57 +0000 (01:23 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 28 Nov 2010 01:05:08 +0000 (02:05 +0100)
* m4/printf.m4 (gl_PRINTF_PRECISION): Detect crash with large precision
for floating-point output.
* tests/test-vasnprintf-posix.c (test_function): Test precision with %f
directive.
* tests/test-snprintf-posix.h (test_function): Likewise.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-vasprintf-posix.c (test_function): Likewise.
* doc/posix-functions/fprintf.texi: Mention Solaris/x86 bug.
* 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/glibc-functions/obstack_printf.texi: Likewise.
* doc/glibc-functions/obstack_vprintf.texi: Likewise.

16 files changed:
ChangeLog
doc/glibc-functions/obstack_printf.texi
doc/glibc-functions/obstack_vprintf.texi
doc/posix-functions/fprintf.texi
doc/posix-functions/printf.texi
doc/posix-functions/snprintf.texi
doc/posix-functions/sprintf.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 eb11d9269d429767e536d55094c7d6a9080f193a..5d975031161781e0029d6a82fb5c04d0d334079d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2010-11-27  Bruno Haible  <bruno@clisp.org>
+
+       *printf-posix: Detect a bug on Solaris 10/x86.
+       * m4/printf.m4 (gl_PRINTF_PRECISION): Detect crash with large precision
+       for floating-point output.
+       * tests/test-vasnprintf-posix.c (test_function): Test precision with %f
+       directive.
+       * tests/test-snprintf-posix.h (test_function): Likewise.
+       * tests/test-sprintf-posix.h (test_function): Likewise.
+       * tests/test-vasprintf-posix.c (test_function): Likewise.
+       * doc/posix-functions/fprintf.texi: Mention Solaris/x86 bug.
+       * 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/glibc-functions/obstack_printf.texi: Likewise.
+       * doc/glibc-functions/obstack_vprintf.texi: Likewise.
+
 2010-11-27  Bruno Haible  <bruno@clisp.org>
 
        Fix link error when module libunistring-optional is in use.
index 929baa6298e7b95d4325c28c00957fd5aa17fea8..070b79789e4b39a3f47e033a11fdaced3745a9c9 100644 (file)
@@ -59,7 +59,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index d930dd477fbfb0f907ae4a9f0c97c76f88bd6cef..c34efd81e475685a3e2521a1972c5fc5a779284c 100644 (file)
@@ -59,7 +59,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index 09de039aee5a10d1a593a004ebe739e9cfade6c7..ab6a91b7c4686fe9c65b0c22b0f9c4fc327b99cc 100644 (file)
@@ -53,7 +53,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index 1d2193961cc8a3770f68c81694e297ab767186d5..742c8d90d85c709ca07b3addac8244d769a0bd53 100644 (file)
@@ -53,7 +53,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index 8e93c74d109b1180cecf47d68bfed75037cf8bd5..2d7379518245356ae1aee643b322a307ed668622 100644 (file)
@@ -64,7 +64,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index 722beaa012e5cd8eaffe35736ae14e44010e2381..cf77bbc712d691b6f315004eb17558ad45f986c3 100644 (file)
@@ -53,7 +53,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index d5d99c48739b7024234db303e4f389a17eeea4ba..209e1b756e1e70fa4abcf7d1204859c7e563c4b9 100644 (file)
@@ -53,7 +53,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index a311bb3ae6e4da5ff16a2d2aee65175ab4b6ee29..890bf659cd224ae21ecc759adcf7aee85f80802e 100644 (file)
@@ -53,7 +53,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index 537714fe0e5ef26b4360c548c616a09347d54fe2..47e8aeaee91e93890e44b8eade0a34790a83723f 100644 (file)
@@ -64,7 +64,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index 377e0c09d40cf08ccfb81f570fcf0b7048336fb6..c6e629d061ad93e0ba52222aeee288d19c241fe8 100644 (file)
@@ -53,7 +53,7 @@ MacOS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, OSF/1 5.1, Solaris 10,
 @item
 This function does not support precisions larger than 512 or 1024 in integer,
 floating-point and pointer output on some platforms:
-mingw, BeOS.
+Solaris 10/x86, mingw, BeOS.
 @item
 This function can crash in out-of-memory conditions on some platforms:
 MacOS X 10.3, FreeBSD 6.0, NetBSD 5.0.
index 0bdd795bf29e51bfadabd7711ccf7dcba522f0c4..9186d21dc8c9b53aa65dfaf277e701e883a1140a 100644 (file)
@@ -1,4 +1,4 @@
-# printf.m4 serial 38
+# printf.m4 serial 39
 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,
@@ -882,8 +882,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 BeOS, precisions larger than 1044
-dnl crash the program.
+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 Result is gl_cv_func_printf_precision.
 
 AC_DEFUN([gl_PRINTF_PRECISION],
@@ -906,6 +907,8 @@ int main ()
 #endif
   if (sprintf (buf, "%.4000d %d", 1, 33, 44) < 4000 + 3)
     return 1;
+  if (sprintf (buf, "%.4000f %d", 1.0, 33, 44) < 4000 + 5)
+    return 2;
   return 0;
 }]])],
         [gl_cv_func_printf_precision=yes],
@@ -913,7 +916,8 @@ int main ()
         [
 changequote(,)dnl
          case "$host_os" in
-           # Guess no only on native Win32 and BeOS systems.
+           # Guess no only on Solaris, native Win32, and BeOS systems.
+           solaris*)     gl_cv_func_printf_precision="guessing no" ;;
            mingw* | pw*) gl_cv_func_printf_precision="guessing no" ;;
            beos*)        gl_cv_func_printf_precision="guessing no" ;;
            *)            gl_cv_func_printf_precision="guessing yes" ;;
@@ -1438,7 +1442,7 @@ dnl   OpenBSD 3.9, 4.0               .  .  #  #  #  #  .  #  .  #  .  #  .  #  .
 dnl   Cygwin 1.7.0 (2009)            .  .  .  #  .  .  .  ?  .  .  .  .  .  ?  .  .  .  .  .  .
 dnl   Cygwin 1.5.25 (2008)           .  .  .  #  #  .  .  #  .  .  .  .  .  #  .  .  .  .  .  .
 dnl   Cygwin 1.5.19 (2006)           #  .  .  #  #  #  .  #  .  #  .  #  #  #  .  .  .  .  .  .
-dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  .  .  .  .  .  .  .  .
+dnl   Solaris 10                     .  .  #  #  #  .  .  #  .  .  .  #  #  .  .  .  .  .  .  .
 dnl   Solaris 2.6 ... 9              #  .  #  #  #  #  .  #  .  .  .  #  .  .  .  .  .  .  .  .
 dnl   Solaris 2.5.1                  #  .  #  #  #  #  .  #  .  .  .  #  .  .  #  #  #  #  #  #
 dnl   AIX 5.2, 7.1                   .  .  #  #  #  .  .  .  .  .  .  #  .  .  .  .  .  .  .  .
index f55e49e4767fe5772538b762e52e360e06afe9dd..37612f9ef44c716a899ec6befba6a975a60c2df5 100644 (file)
@@ -3031,6 +3031,19 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
     ASSERT (retval == strlen (result));
   }
 
+  {
+    char result[5000];
+    int retval =
+      my_snprintf (result, sizeof (result), "%.4000f %d", 1.0, 99);
+    size_t i;
+    ASSERT (result[0] == '1');
+    ASSERT (result[1] == '.');
+    for (i = 0; i < 4000; i++)
+      ASSERT (result[2 + i] == '0');
+    ASSERT (strcmp (result + 2 + 4000, " 99") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
   {
     char input[5000];
     char result[5000];
index 3abe27e60ef2977af252092f006d7aae1d2390f7..ff162aa87728622959df11a1b4b9522e86d49c56 100644 (file)
@@ -3017,6 +3017,19 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
     ASSERT (retval == strlen (result));
   }
 
+  {
+    char result[5000];
+    int retval =
+      my_sprintf (result, "%.4000f %d", 1.0, 99);
+    size_t i;
+    ASSERT (result[0] == '1');
+    ASSERT (result[1] == '.');
+    for (i = 0; i < 4000; i++)
+      ASSERT (result[2 + i] == '0');
+    ASSERT (strcmp (result + 2 + 4000, " 99") == 0);
+    ASSERT (retval == strlen (result));
+  }
+
   {
     char input[5000];
     char result[5000];
index 87c58985fd50714e168253a6c56bc4b1d5ab6108..dd98691ad0da9f32f15e8f01056c7dcde7ef7c4e 100644 (file)
@@ -3552,6 +3552,21 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
     free (result);
   }
 
+  {
+    size_t length;
+    char *result =
+      my_asnprintf (NULL, &length, "%.4000f %d", 1.0, 99);
+    size_t i;
+    ASSERT (result != NULL);
+    ASSERT (result[0] == '1');
+    ASSERT (result[1] == '.');
+    for (i = 0; i < 4000; i++)
+      ASSERT (result[2 + i] == '0');
+    ASSERT (strcmp (result + 2 + 4000, " 99") == 0);
+    ASSERT (length == strlen (result));
+    free (result);
+  }
+
   {
     char input[5000];
     size_t length;
index cd48493b810454c78709fde41b4cb0a7cf5e2172..8f71c4f974ae35ab98abce560aea7a17917f40c8 100644 (file)
@@ -3532,6 +3532,21 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
     free (result);
   }
 
+  {
+    char *result;
+    int retval =
+      my_asprintf (&result, "%.4000f %d", 1.0, 99);
+    size_t i;
+    ASSERT (result != NULL);
+    ASSERT (result[0] == '1');
+    ASSERT (result[1] == '.');
+    for (i = 0; i < 4000; i++)
+      ASSERT (result[2 + i] == '0');
+    ASSERT (strcmp (result + 2 + 4000, " 99") == 0);
+    ASSERT (retval == strlen (result));
+    free (result);
+  }
+
   {
     char input[5000];
     char *result;