about summary refs log tree commit diff
path: root/stdio-common
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-08-23 06:35:22 +0000
committerUlrich Drepper <drepper@redhat.com>2000-08-23 06:35:22 +0000
commit6c46718f9f0dc0756860988c36eacdefe1cd27a6 (patch)
treef75fc09a31a8e1d3c26f0796a48bf771e9f43d49 /stdio-common
parentcf970a32156e60e8842c5e9e82a3cb147dacaf64 (diff)
downloadglibc-6c46718f9f0dc0756860988c36eacdefe1cd27a6.tar.gz
glibc-6c46718f9f0dc0756860988c36eacdefe1cd27a6.tar.xz
glibc-6c46718f9f0dc0756860988c36eacdefe1cd27a6.zip
Update.
	* stdio-common/vfprintf.c: Handle %F format.
	* stdio-common/printf-parse.h (parse_one_spec): Likewise.
	Reported by Joseph S. Myers <jsm28@cam.ac.uk>.

	* stdio-common/tstdiomisc.c: Add test for %F printf format.

	* po/zh.po: New file.
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/printf-parse.h1
-rw-r--r--stdio-common/tstdiomisc.c35
-rw-r--r--stdio-common/vfprintf.c14
3 files changed, 43 insertions, 7 deletions
diff --git a/stdio-common/printf-parse.h b/stdio-common/printf-parse.h
index 1f2878a5fc..4a228a1cb8 100644
--- a/stdio-common/printf-parse.h
+++ b/stdio-common/printf-parse.h
@@ -390,6 +390,7 @@ parse_one_spec (const UCHAR_T *format, size_t posn, struct printf_spec *spec,
 	case L'e':
 	case L'E':
 	case L'f':
+	case L'F':
 	case L'g':
 	case L'G':
 	case L'a':
diff --git a/stdio-common/tstdiomisc.c b/stdio-common/tstdiomisc.c
index 1affac5b51..55d77b0f29 100644
--- a/stdio-common/tstdiomisc.c
+++ b/stdio-common/tstdiomisc.c
@@ -1,4 +1,8 @@
+#include <float.h>
+#include <math.h>
 #include <stdio.h>
+#include <string.h>
+#include <wchar.h>
 
 int
 t1 (void)
@@ -43,12 +47,43 @@ t2 (void)
 }
 
 int
+F (void)
+{
+  char buf[20];
+  wchar_t wbuf[10];
+  int result;
+
+  snprintf (buf, sizeof buf, "%f %F", DBL_MAX * DBL_MAX - DBL_MAX * DBL_MAX,
+	    DBL_MAX * DBL_MAX - DBL_MAX * DBL_MAX);
+  result = strcmp (buf, "nan NAN") != 0;
+  printf ("expected \"nan NAN\", got \"%s\"\n", buf);
+
+  snprintf (buf, sizeof buf, "%f %F", DBL_MAX * DBL_MAX, DBL_MAX * DBL_MAX);
+  result |= strcmp (buf, "inf INF") != 0;
+  printf ("expected \"inf INF\", got \"%s\"\n", buf);
+
+  swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%f %F",
+	    DBL_MAX * DBL_MAX - DBL_MAX * DBL_MAX,
+	    DBL_MAX * DBL_MAX - DBL_MAX * DBL_MAX);
+  result |= wcscmp (wbuf, L"nan NAN") != 0;
+  printf ("expected L\"nan NAN\", got L\"%S\"\n", wbuf);
+
+  swprintf (wbuf, sizeof wbuf / sizeof (wbuf[0]), L"%f %F",
+	    DBL_MAX * DBL_MAX, DBL_MAX * DBL_MAX);
+  result |= wcscmp (wbuf, L"inf INF") != 0;
+  printf ("expected L\"inf INF\", got L\"%S\"\n", wbuf);
+
+  return result;
+}
+
+int
 main (int argc, char *argv[])
 {
   int result = 0;
 
   result |= t1 ();
   result |= t2 ();
+  result |= F ();
 
   result |= fflush (stdout) == EOF;
 
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 3f13026e14..b90f26f7fa 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -284,7 +284,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
     /* '8' */  8, /* '9' */  8,            0,            0,
 	       0,            0,            0,            0,
 	       0, /* 'A' */ 26,            0, /* 'C' */ 25,
-	       0, /* 'E' */ 19,            0, /* 'G' */ 19,
+	       0, /* 'E' */ 19, /* F */   19, /* 'G' */ 19,
 	       0, /* 'I' */ 29,            0,            0,
     /* 'L' */ 12,            0,            0,            0,
 	       0,            0,            0, /* 'S' */ 21,
@@ -354,7 +354,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       REF (form_unsigned),	/* for 'u' */				      \
       REF (form_octal),		/* for 'o' */				      \
       REF (form_hexa),		/* for 'X', 'x' */			      \
-      REF (form_float),		/* for 'E', 'e', 'f', 'G', 'g' */	      \
+      REF (form_float),		/* for 'E', 'e', 'F', 'f', 'G', 'g' */	      \
       REF (form_character),	/* for 'c' */				      \
       REF (form_string),	/* for 's', 'S' */			      \
       REF (form_pointer),	/* for 'p' */				      \
@@ -388,7 +388,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       REF (form_unsigned),	/* for 'u' */				      \
       REF (form_octal),		/* for 'o' */				      \
       REF (form_hexa),		/* for 'X', 'x' */			      \
-      REF (form_float),		/* for 'E', 'e', 'f', 'G', 'g' */	      \
+      REF (form_float),		/* for 'E', 'e', 'F', 'f', 'G', 'g' */	      \
       REF (form_character),	/* for 'c' */				      \
       REF (form_string),	/* for 's', 'S' */			      \
       REF (form_pointer),	/* for 'p' */				      \
@@ -422,7 +422,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       REF (form_unsigned),	/* for 'u' */				      \
       REF (form_octal),		/* for 'o' */				      \
       REF (form_hexa),		/* for 'X', 'x' */			      \
-      REF (form_float),		/* for 'E', 'e', 'f', 'G', 'g' */	      \
+      REF (form_float),		/* for 'E', 'e', 'F', 'f', 'G', 'g' */	      \
       REF (form_character),	/* for 'c' */				      \
       REF (form_string),	/* for 's', 'S' */			      \
       REF (form_pointer),	/* for 'p' */				      \
@@ -456,7 +456,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       REF (form_unsigned),	/* for 'u' */				      \
       REF (form_octal),		/* for 'o' */				      \
       REF (form_hexa),		/* for 'X', 'x' */			      \
-      REF (form_unknown),	/* for 'E', 'e', 'f', 'G', 'g' */	      \
+      REF (form_unknown),	/* for 'E', 'e', 'F', 'f', 'G', 'g' */	      \
       REF (form_unknown),	/* for 'c' */				      \
       REF (form_unknown),	/* for 's', 'S' */			      \
       REF (form_unknown),	/* for 'p' */				      \
@@ -490,7 +490,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       REF (form_unsigned),	/* for 'u' */				      \
       REF (form_octal),		/* for 'o' */				      \
       REF (form_hexa),		/* for 'X', 'x' */			      \
-      REF (form_float),		/* for 'E', 'e', 'f', 'G', 'g' */	      \
+      REF (form_float),		/* for 'E', 'e', 'F', 'f', 'G', 'g' */	      \
       REF (form_character),	/* for 'c' */				      \
       REF (form_string),	/* for 's', 'S' */			      \
       REF (form_pointer),	/* for 'p' */				      \
@@ -526,7 +526,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
       REF (form_unsigned),	/* for 'u' */				      \
       REF (form_octal),		/* for 'o' */				      \
       REF (form_hexa),		/* for 'X', 'x' */			      \
-      REF (form_float),		/* for 'E', 'e', 'f', 'G', 'g' */	      \
+      REF (form_float),		/* for 'E', 'e', 'F', 'f', 'G', 'g' */	      \
       REF (form_character),	/* for 'c' */				      \
       REF (form_string),	/* for 's', 'S' */			      \
       REF (form_pointer),	/* for 'p' */				      \