]> Savannah Git Hosting - gnulib.git/commitdiff
*printf: Work around rounding bug on Mac OS X.
authorBruno Haible <bruno@clisp.org>
Sat, 22 Apr 2017 14:27:45 +0000 (16:27 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 22 Apr 2017 14:27:45 +0000 (16:27 +0200)
* m4/printf.m4 (gl_PRINTF_DIRECTIVE_A): Test for Mac OS X 10.12 bug.
* doc/posix-functions/*printf.texi: Mention the rounding bugs of
Mac OS X and FreeBSD.
* doc/glibc-functions/*printf.texi: Likewise.

14 files changed:
ChangeLog
doc/glibc-functions/asprintf.texi
doc/glibc-functions/obstack_printf.texi
doc/glibc-functions/obstack_vprintf.texi
doc/glibc-functions/vasprintf.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

index 13ae5470bf9a4f89306940ff0f8db82f98397268..d44f5d8a0cfab1fd5536ed25371f657f1c93d3a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-04-22  Bruno Haible  <bruno@clisp.org>
+
+       *printf: Work around rounding bug on Mac OS X.
+       * m4/printf.m4 (gl_PRINTF_DIRECTIVE_A): Test for Mac OS X 10.12 bug.
+       * doc/posix-functions/*printf.texi: Mention the rounding bugs of
+       Mac OS X and FreeBSD.
+       * doc/glibc-functions/*printf.texi: Likewise.
+
 2017-04-22  Bruno Haible  <bruno@clisp.org>
 
        vasnprintf tests: Avoid warnings.
index ae57d822496d7a136c6961b6886b47d3e68aca66..4baf95a060424f27afa22cc3e637da4dc9f44960 100644 (file)
@@ -46,6 +46,10 @@ NetBSD 3.0, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, Solaris 11 2011-11, Cygwin 1.5.x.
index 31e4d1e3fd4a001190db3becacf146844193396a..d1caad3900f5fc022e8fcf573ed383b72571cb2d 100644 (file)
@@ -52,6 +52,10 @@ NetBSD 3.0, mingw, MSVC 9, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index 9cb53117c27c59ef4313075c36919a54decfb6c1..630b1e2399f03cfe771c8ed0a1975250f855354a 100644 (file)
@@ -52,6 +52,10 @@ NetBSD 3.0, mingw, MSVC 9, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index 05651ceab3ff7f8302d5a5828c66f3b156f43630..056121ef4fd9a2a00d8282ec5aca9ec1cee73245 100644 (file)
@@ -46,6 +46,10 @@ NetBSD 3.0, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
 with zeroes) on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, Solaris 11 2011-11, Cygwin 1.5.x.
index f4a6d5e75d30d89f93aa588303d01a225801de2a..da764de78f1124c6c4d2446e4ba271a623b347e3 100644 (file)
@@ -46,6 +46,10 @@ NetBSD 3.0, mingw, MSVC 9, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index 79537c973e8960a7792515a4d9f9d34a49fe96bf..2701cf29f882bb383530e72099211e7a7f56b09f 100644 (file)
@@ -46,6 +46,10 @@ NetBSD 3.0, mingw, MSVC 9, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index 76c88fa193c56174ab5861b93fc1aa25b0bbd76c..e7f2c51bd1c305fb0df522b757e6f206f2bc728b 100644 (file)
@@ -61,6 +61,10 @@ Solaris 11 2011-11.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index 63b38bf8cb4062f76aba650d3acdb09e9aba46d1..53a77e3914aca303414c197d66a3ef5b5b5f17e9 100644 (file)
@@ -46,6 +46,10 @@ NetBSD 3.0, mingw, MSVC 9, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index 00f103fea93cfcdc6b577b9af666c42a6b76e014..9ff9d163afdde21216b0593d1bd7c2fe855133cc 100644 (file)
@@ -46,6 +46,10 @@ NetBSD 3.0, mingw, MSVC 9, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index a7bcf51d89cc59d2c8a405ead7af7ea544998e69..6b87b90383217fe894b580bd16942e8b098c4ebe 100644 (file)
@@ -46,6 +46,10 @@ NetBSD 3.0, mingw, MSVC 9, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index 495647fac5f3461a5cae24d401e7a36496a02799..13ac7bdac0006b706714941d83ae8e614536aa46 100644 (file)
@@ -58,6 +58,10 @@ Solaris 11 2011-11.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index 723e4d5010e1ed7771153a1fb6496f1ae09054fa..be7ca48b23be99038738f85047f230e4fda85896 100644 (file)
@@ -46,6 +46,10 @@ NetBSD 3.0, mingw, MSVC 9, BeOS.
 This function doesn't support the @code{'} flag on some platforms:
 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 9.
 @item
+This function does not round the argument of the @samp{a} directive correctly
+on some platforms:
+Mac OS X 10.12, FreeBSD 6.1.
+@item
 This function behaves incorrectly when a @samp{-} flag and a negative width
 are specified together, on some platforms:
 HP-UX 10.20.
index a44ac66b8f8291188ffec4da1d5e0abadb643641..113cc2e606d73f7385cdaa0ea5e9b796ad6ef446 100644 (file)
@@ -1,4 +1,4 @@
-# printf.m4 serial 52
+# printf.m4 serial 53
 dnl Copyright (C) 2003, 2007-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -489,6 +489,13 @@ int main ()
           && strcmp (buf, "0x6.0ap-2 33") != 0
           && strcmp (buf, "0xc.14p-3 33") != 0))
     result |= 4;
+  /* This catches a Mac OS X 10.12.4 (Darwin 16.5) bug: it doesn't round.  */
+  if (sprintf (buf, "%.0a %d", 1.51, 33, 44, 55) < 0
+      || (strcmp (buf, "0x2p+0 33") != 0
+          && strcmp (buf, "0x3p-1 33") != 0
+          && strcmp (buf, "0x6p-2 33") != 0
+          && strcmp (buf, "0xcp-3 33") != 0))
+    result |= 4;
   /* 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 / zero, 33, 44, 55) < 0