aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-07-07 21:38:43 +0000
committerUlrich Drepper <drepper@redhat.com>2007-07-07 21:38:43 +0000
commite9055017f6d2015c4c74c94b1c2bf59968db223f (patch)
tree81fd5f6ba0e21c9d2d9465120e710248649191c1
parentc2c7bd3f865be02443c65e9a4e57b7d96cde145a (diff)
downloadglibc-e9055017f6d2015c4c74c94b1c2bf59968db223f.tar
glibc-e9055017f6d2015c4c74c94b1c2bf59968db223f.tar.gz
glibc-e9055017f6d2015c4c74c94b1c2bf59968db223f.tar.bz2
glibc-e9055017f6d2015c4c74c94b1c2bf59968db223f.zip
* libio/wstrops.c (_IO_wstr_underflow): Clear errno before
returning WEOF. * stdio-common/Makefile (tests): Add bug18a. * stdio-common/bug18a.c: New file.
-rw-r--r--ChangeLog5
-rw-r--r--libio/wstrops.c10
-rw-r--r--stdio-common/Makefile2
-rw-r--r--stdio-common/bug18.c10
-rw-r--r--stdio-common/bug18a.c6
5 files changed, 28 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 71e1e5b74e..a8f842ca14 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2007-07-07 Ulrich Drepper <drepper@redhat.com>
+ * libio/wstrops.c (_IO_wstr_underflow): Clear errno before
+ returning WEOF.
+ * stdio-common/Makefile (tests): Add bug18a.
+ * stdio-common/bug18a.c: New file.
+
[BZ #4745]
* libio/strops.c (_IO_str_underflow): Clear errno before returning
EOF.
diff --git a/libio/wstrops.c b/libio/wstrops.c
index c5aae7bc6a..dfb312f6b7 100644
--- a/libio/wstrops.c
+++ b/libio/wstrops.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1993,1997-1999,2001-2004, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1993,1997-1999,2001-2004,2006,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
@@ -154,7 +155,12 @@ _IO_wstr_underflow (fp)
if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
return *fp->_wide_data->_IO_read_ptr;
else
- return WEOF;
+ {
+ /* We have to reset errno since callers check for errno being
+ EINTR and there has been no such problem here. */
+ __set_errno (0);
+ return WEOF;
+ }
}
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 57797c7f2b..d8f095ed55 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -54,7 +54,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
tst-swprintf tst-fseek tst-fmemopen test-vfprintf tst-gets \
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
+ tst-fwrite bug16 bug17 tst-swscanf tst-sprintf2 bug18 bug18a
test-srcs = tst-unbputc tst-printf
diff --git a/stdio-common/bug18.c b/stdio-common/bug18.c
index c3a86e5786..2e4c378c13 100644
--- a/stdio-common/bug18.c
+++ b/stdio-common/bug18.c
@@ -2,6 +2,12 @@
#include <errno.h>
#include <stdio.h>
+#ifndef CHAR
+# define CHAR char
+# define L(str) str
+# define SSCANF sscanf
+#endif
+
static int
do_test (void)
@@ -11,11 +17,11 @@ do_test (void)
printf("checking sscanf\n");
- char str[] = "7-11";
+ CHAR str[] = L("7-11");
int i, j, n;
i = j = n = 0;
- sscanf (str, " %i - %i %n", &i, &j, &n);
+ SSCANF (str, L(" %i - %i %n"), &i, &j, &n);
printf ("found %i-%i (length=%i)\n", i, j, n);
int result = 0;
diff --git a/stdio-common/bug18a.c b/stdio-common/bug18a.c
new file mode 100644
index 0000000000..663cbf4fb7
--- /dev/null
+++ b/stdio-common/bug18a.c
@@ -0,0 +1,6 @@
+#include <wchar.h>
+#define CHAR wchar_t
+#define L(str) L##str
+#define SSCANF swscanf
+
+#include "bug18.c"