summaryrefslogtreecommitdiff
path: root/stdio-common
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-05-04 10:05:57 +0000
committerJakub Jelinek <jakub@redhat.com>2007-05-04 10:05:57 +0000
commit2a0a747e57ec96bab9d4a6b7c0b32df82a41316e (patch)
tree002d92f89d7109abc1c2ebe7f113f8dee0dc3034 /stdio-common
parentaf5726aed8a0c87d7f29570641cf0acb6a92f918 (diff)
Updated to fedora-glibc-20070504T0917cvs/fedora-glibc-2_5_90-22
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/printf_fp.c8
-rw-r--r--stdio-common/test-vfprintf.c8
-rw-r--r--stdio-common/tfformat.c2
-rw-r--r--stdio-common/tstscanf.c4
-rw-r--r--stdio-common/vfprintf.c25
-rw-r--r--stdio-common/vfscanf.c5
6 files changed, 34 insertions, 18 deletions
diff --git a/stdio-common/printf_fp.c b/stdio-common/printf_fp.c
index 9b796eac2f..6e5ff5855b 100644
--- a/stdio-common/printf_fp.c
+++ b/stdio-common/printf_fp.c
@@ -793,7 +793,7 @@ ___printf_fp (FILE *fp,
else
{
/* This is a special case. We don't need a factor because the
- numbers are in the range of 0.0 <= fp < 8.0. We simply
+ numbers are in the range of 1.0 <= |fp| < 8.0. We simply
shift it to the right place and divide it by 1.0 to get the
leading digit. (Of course this division is not really made.) */
assert (0 <= exponent && exponent < 3 &&
@@ -1013,6 +1013,12 @@ ___printf_fp (FILE *fp,
{
*wstartp = '1';
exponent += expsign == 0 ? 1 : -1;
+
+ /* The above exponent adjustment could lead to 1.0e-00,
+ e.g. for 0.999999999. Make sure exponent 0 always
+ uses + sign. */
+ if (exponent == 0)
+ expsign = 0;
}
else if (intdig_no == dig_max)
{
diff --git a/stdio-common/test-vfprintf.c b/stdio-common/test-vfprintf.c
index a683eac779..342ac471da 100644
--- a/stdio-common/test-vfprintf.c
+++ b/stdio-common/test-vfprintf.c
@@ -1,5 +1,5 @@
/* Tests of *printf for very large strings.
- Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2003, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2000.
@@ -94,6 +94,7 @@ main (void)
fprintf (fp, "%.*s", 30000, large);
large[20000] = '\0';
fprintf (fp, large);
+ fprintf (fp, "%-1.300000000s", "hello");
if (fflush (fp) != 0 || ferror (fp) != 0 || fclose (fp) != 0)
{
@@ -108,11 +109,12 @@ main (void)
setlocale (LC_ALL, NULL));
exit (1);
}
- else if (st.st_size != 99999)
+ else if (st.st_size != 50000 + 30000 + 19999 + 5)
{
printf ("file size incorrect for locale %s: %jd instead of %jd\n",
setlocale (LC_ALL, NULL),
- (intmax_t) st.st_size, (intmax_t) 99999);
+ (intmax_t) st.st_size,
+ (intmax_t) 50000 + 30000 + 19999 + 5);
res = 1;
}
else
diff --git a/stdio-common/tfformat.c b/stdio-common/tfformat.c
index 259e2e0b18..d67b3b504d 100644
--- a/stdio-common/tfformat.c
+++ b/stdio-common/tfformat.c
@@ -4021,6 +4021,8 @@ sprint_double_type sprint_doubles[] =
{__LINE__, 0.000098, "0.0001", "%#.0g"},
{__LINE__, 0.0000996, "0.00010", "%#.2g"},
{__LINE__, 9.999999999999999e-05, "0.0001", "%g"},
+ {__LINE__, 1.0, "1.000000e+00", "%e"},
+ {__LINE__, .9999999999999999, "1.000000e+00", "%e"},
{0 }
diff --git a/stdio-common/tstscanf.c b/stdio-common/tstscanf.c
index 44ddf49e15..123d733e3f 100644
--- a/stdio-common/tstscanf.c
+++ b/stdio-common/tstscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,92,96,97,98,99,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,1996-2001,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -272,7 +272,7 @@ main (int argc, char **argv)
res = sscanf ("0x1234", "%lf", &d);
printf ("res = %d, d = %f\n", res, d);
- if (res != 0 || d != 123456.789)
+ if (res != 1 || d != 4660)
{
fputs ("test failed!\n", stdout);
result = 1;
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 946551f2d6..4f0d971c55 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1160,19 +1160,26 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
else \
{ \
/* In case we have a multibyte character set the \
- situation is more compilcated. We must not copy \
+ situation is more complicated. We must not copy \
bytes at the end which form an incomplete character. */\
- wchar_t ignore[prec]; \
+ size_t ignore_size = (unsigned) prec > 1024 ? 1024 : prec;\
+ wchar_t ignore[ignore_size]; \
const char *str2 = string; \
- mbstate_t ps; \
+ const char *strend = string + prec; \
+ if (strend < string) \
+ strend = (const char *) UINTPTR_MAX; \
\
+ mbstate_t ps; \
memset (&ps, '\0', sizeof (ps)); \
- if (__mbsnrtowcs (ignore, &str2, prec, prec, &ps) \
- == (size_t) -1) \
- { \
- done = -1; \
- goto all_done; \
- } \
+ \
+ while (str2 != NULL && str2 < strend) \
+ if (__mbsnrtowcs (ignore, &str2, strend - str2, \
+ ignore_size, &ps) == (size_t) -1) \
+ { \
+ done = -1; \
+ goto all_done; \
+ } \
+ \
if (str2 == NULL) \
len = strlen (string); \
else \
diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c
index 0daf4ae0dd..b1469b9a9e 100644
--- a/stdio-common/vfscanf.c
+++ b/stdio-common/vfscanf.c
@@ -2028,10 +2028,9 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr,
/* Have we read any character? If we try to read a number
in hexadecimal notation and we have read only the `0x'
- prefix or no exponent this is an error. */
+ prefix this is an error. */
if (__builtin_expect (wpsize == 0
- || ((flags & HEXA_FLOAT)
- && (wpsize == 2 || ! got_e)), 0))
+ || ((flags & HEXA_FLOAT) && wpsize == 2), 0))
conv_error ();
scan_float: