about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-31 12:42:39 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-31 12:42:39 +0000
commit6120b32908175af07582fa64289228a5c71edcb6 (patch)
treeb4d4fee2615a1081b187e622fa63cceb4c7020d4
parent78a2b0ca2e6d454eb2882ba0f7e74d58dce579dc (diff)
downloadglibc-6120b32908175af07582fa64289228a5c71edcb6.tar.gz
glibc-6120b32908175af07582fa64289228a5c71edcb6.tar.xz
glibc-6120b32908175af07582fa64289228a5c71edcb6.zip
2007-07-31 Jakub Jelinek <jakub@redhat.com>
	* stdio-common/tfformat.c (sprint_doubles): Add 12 new tests.

2007-07-28  Ulrich Drepper  <drepper@redhat.com>

	[BZ #4858]
	* stdio-common/printf_fp.c (___printf_fp): Fix special case of
	#.0g and value rounded to 1.0.
	* stdio-common/tfformat.c (sprint_doubles): Add two new tests.
-rw-r--r--ChangeLog11
-rw-r--r--stdio-common/printf_fp.c4
-rw-r--r--stdio-common/tfformat.c15
3 files changed, 29 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 872cf8cb4e..8ae1bd2f5a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-07-31  Jakub Jelinek  <jakub@redhat.com>
+
+	* stdio-common/tfformat.c (sprint_doubles): Add 12 new tests.
+
+2007-07-28  Ulrich Drepper  <drepper@redhat.com>
+
+	[BZ #4858]
+	* stdio-common/printf_fp.c (___printf_fp): Fix special case of
+	#.0g and value rounded to 1.0.
+	* stdio-common/tfformat.c (sprint_doubles): Add two new tests.
+
 2007-06-04  Jakub Jelinek  <jakub@redhat.com>
 
 	* math/test-misc.c (main): Don't run last batch of tests with
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 6e5ff5855b..ae25ab6fc5 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -986,7 +986,9 @@ ___printf_fp (FILE *fp,
 	    if (*wtp != decimalwc)
 	      /* Round up.  */
 	      (*wtp)++;
-	    else if (__builtin_expect (spec == 'g' && type == 'f' && info->alt,
+	    else if (__builtin_expect (spec == 'g' && type == 'f' && info->alt
+				       && wtp == wstartp + 1
+				       && wstartp[0] == L'0',
 				       0))
 	      /* This is a special case: the rounded number is 1.0,
 		 the format is 'g' or 'G', and the alternative format
diff --git a/stdio-common/tfformat.c b/stdio-common/tfformat.c
index d67b3b504d..7704ddde39 100644
--- a/stdio-common/tfformat.c
+++ b/stdio-common/tfformat.c
@@ -4024,6 +4024,21 @@ sprint_double_type sprint_doubles[] =
   {__LINE__, 1.0,			"1.000000e+00", "%e"},
   {__LINE__, .9999999999999999,		"1.000000e+00", "%e"},
 
+  {__LINE__, 912.98,			"913.0", "%#.4g"},
+  {__LINE__, 50.999999,			"51.000", "%#.5g"},
+  {__LINE__, 0.956,			"1", "%.1g"},
+  {__LINE__, 0.956,			"1.", "%#.1g"},
+  {__LINE__, 0.996,			"1", "%.2g"},
+  {__LINE__, 0.996,			"1.0", "%#.2g"},
+  {__LINE__, 999.98,			"1000", "%.4g"},
+  {__LINE__, 999.98,			"1000.", "%#.4g"},
+  {__LINE__, 999.998,			"1000", "%.5g"},
+  {__LINE__, 999.998,			"1000.0", "%#.5g"},
+  {__LINE__, 999.9998,			"1000", "%g"},
+  {__LINE__, 999.9998,			"1000.00", "%#g"},
+  {__LINE__, 912.98,			"913", "%.4g"},
+  {__LINE__, 50.999999,			"51", "%.5g"},
+
   {0 }
 
 };