summaryrefslogtreecommitdiff
path: root/stdio-common
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-31 17:46:17 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-31 17:46:17 +0000
commit8833066b122427710a9e14a888ce6cfa862332d3 (patch)
tree29591019d695919417b3698618d6a342e97381d6 /stdio-common
parentfedca46896bdb702cb988837a0c2c5447e72ba2b (diff)
Updated to fedora-glibc-20070731T1624cvs/fedora-glibc-2_6_90-1
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/Makefile3
-rw-r--r--stdio-common/printf_fp.c4
-rw-r--r--stdio-common/tfformat.c15
-rw-r--r--stdio-common/tst-popen2.c92
-rw-r--r--stdio-common/tst-sprintf2.c2
-rw-r--r--stdio-common/vfprintf.c2
6 files changed, 115 insertions, 3 deletions
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 4ead0f9574..104c0e0d91 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -55,7 +55,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
tst-fwrite bug16 bug17 tst-swscanf tst-sprintf2 bug18 bug18a \
- bug19 bug19a
+ bug19 bug19a tst-popen2
test-srcs = tst-unbputc tst-printf
@@ -78,6 +78,7 @@ $(objpfx)tst-printf.out: $(objpfx)tst-printf tst-printf.sh
endif
CFLAGS-vfprintf.c = -Wno-uninitialized
+CFLAGS-vfwprintf.c = -Wno-uninitialized
CFLAGS-tst-printf.c = -Wno-format
CFLAGS-tstdiomisc.c = -Wno-format
CFLAGS-scanf4.c = -Wno-format
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 }
};
diff --git a/stdio-common/tst-popen2.c b/stdio-common/tst-popen2.c
new file mode 100644
index 0000000000..0ab151c598
--- /dev/null
+++ b/stdio-common/tst-popen2.c
@@ -0,0 +1,92 @@
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+static int
+do_test (void)
+{
+ int fd = dup (fileno (stdout));
+ if (fd <= 1)
+ {
+ puts ("dup failed");
+ return 1;
+ }
+
+ FILE *f1 = fdopen (fd, "w");
+ if (f1 == NULL)
+ {
+ printf ("fdopen failed: %m\n");
+ return 1;
+ }
+
+ fclose (stdout);
+
+ FILE *f2 = popen ("echo test1", "r");
+ if (f2 == NULL)
+ {
+ fprintf (f1, "1st popen failed: %m\n");
+ return 1;
+ }
+ FILE *f3 = popen ("echo test2", "r");
+ if (f2 == NULL || f3 == NULL)
+ {
+ fprintf (f1, "2nd popen failed: %m\n");
+ return 1;
+ }
+
+ char *line = NULL;
+ size_t len = 0;
+ int result = 0;
+ if (getline (&line, &len, f2) != 6)
+ {
+ fputs ("could not read line from 1st popen\n", f1);
+ result = 1;
+ }
+ else if (strcmp (line, "test1\n") != 0)
+ {
+ fprintf (f1, "read \"%s\"\n", line);
+ result = 1;
+ }
+
+ if (getline (&line, &len, f2) != -1)
+ {
+ fputs ("second getline did not return -1\n", f1);
+ result = 1;
+ }
+
+ if (getline (&line, &len, f3) != 6)
+ {
+ fputs ("could not read line from 2nd popen\n", f1);
+ result = 1;
+ }
+ else if (strcmp (line, "test2\n") != 0)
+ {
+ fprintf (f1, "read \"%s\"\n", line);
+ result = 1;
+ }
+
+ if (getline (&line, &len, f3) != -1)
+ {
+ fputs ("second getline did not return -1\n", f1);
+ result = 1;
+ }
+
+ int ret = pclose (f2);
+ if (ret != 0)
+ {
+ fprintf (f1, "1st pclose returned %d\n", ret);
+ result = 1;
+ }
+
+ ret = pclose (f3);
+ if (ret != 0)
+ {
+ fprintf (f1, "2nd pclose returned %d\n", ret);
+ result = 1;
+ }
+
+ return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/stdio-common/tst-sprintf2.c b/stdio-common/tst-sprintf2.c
index debb68e21f..422278dd6a 100644
--- a/stdio-common/tst-sprintf2.c
+++ b/stdio-common/tst-sprintf2.c
@@ -6,8 +6,10 @@
int
main (void)
{
+#if LDBL_MANT_DIG >= 106
volatile union { long double l; long long x[2]; } u, v;
char buf[64];
+#endif
int result = 0;
#if LDBL_MANT_DIG == 106 || LDBL_MANT_DIG == 113
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 25edde7511..fae0f7464e 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1298,7 +1298,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
memset (&mbstate, '\0', sizeof (mbstate_t));
/* Find the first format specifier. */
- f = lead_str_end = __find_specmb (format, &mbstate);
+ f = lead_str_end = __find_specmb ((const UCHAR_T *) format, &mbstate);
#endif
/* Lock stream. */