|
|
00db10 |
commit 49051f8ea4551229fa656eba04031af51a5491c5
|
|
|
00db10 |
Author: Joseph Myers <joseph@codesourcery.com>
|
|
|
00db10 |
Date: Thu Nov 27 16:01:04 2014 +0000
|
|
|
00db10 |
|
|
|
00db10 |
Fix libio/bug-ungetwc1.c warning.
|
|
|
00db10 |
|
|
|
00db10 |
This patch fixes a warning "variable 'wc' set but not used" in
|
|
|
00db10 |
libio/bug-ungetwc1.c.
|
|
|
00db10 |
|
|
|
00db10 |
The test didn't verify much about the results of the functions it
|
|
|
00db10 |
called. This patch makes it check the result of getwc (thereby fixing
|
|
|
00db10 |
the warning), check end of file does not arrive too late in the getwc
|
|
|
00db10 |
loop, and check EOF is no longer set after ungetwc.
|
|
|
00db10 |
|
|
|
00db10 |
Tested for x86_64.
|
|
|
00db10 |
|
|
|
00db10 |
* libio/bug-ungetwc1.c (do_test): Verify results of getwc and
|
|
|
00db10 |
feof.
|
|
|
00db10 |
|
|
|
00db10 |
diff --git a/libio/bug-ungetwc1.c b/libio/bug-ungetwc1.c
|
|
|
00db10 |
index 8ed6acd175e86858..56a3d336ae89d69f 100644
|
|
|
00db10 |
--- a/libio/bug-ungetwc1.c
|
|
|
00db10 |
+++ b/libio/bug-ungetwc1.c
|
|
|
00db10 |
@@ -53,8 +53,22 @@ do_test (void)
|
|
|
00db10 |
/* Read from the file. */
|
|
|
00db10 |
fp = fopen (fname, "r");
|
|
|
00db10 |
|
|
|
00db10 |
+ size_t i = 0;
|
|
|
00db10 |
while (!feof (fp))
|
|
|
00db10 |
- wc = getwc (fp);
|
|
|
00db10 |
+ {
|
|
|
00db10 |
+ wc = getwc (fp);
|
|
|
00db10 |
+ if (i >= sizeof (write_chars))
|
|
|
00db10 |
+ {
|
|
|
00db10 |
+ printf ("Did not get end-of-file when expected.\n");
|
|
|
00db10 |
+ return 1;
|
|
|
00db10 |
+ }
|
|
|
00db10 |
+ else if (wc != (write_chars[i] ? write_chars[i] : WEOF))
|
|
|
00db10 |
+ {
|
|
|
00db10 |
+ printf ("Unexpected %lu from getwc.\n", (unsigned long int) wc);
|
|
|
00db10 |
+ return 1;
|
|
|
00db10 |
+ }
|
|
|
00db10 |
+ i++;
|
|
|
00db10 |
+ }
|
|
|
00db10 |
printf ("\nThe end-of-file indicator is set.\n");
|
|
|
00db10 |
|
|
|
00db10 |
/* Unget a wide character. */
|
|
|
00db10 |
@@ -63,7 +77,10 @@ do_test (void)
|
|
|
00db10 |
|
|
|
00db10 |
/* Check the end-of-file indicator. */
|
|
|
00db10 |
if (feof (fp))
|
|
|
00db10 |
- printf ("The end-of-file indicator is still set.\n");
|
|
|
00db10 |
+ {
|
|
|
00db10 |
+ printf ("The end-of-file indicator is still set.\n");
|
|
|
00db10 |
+ return 1;
|
|
|
00db10 |
+ }
|
|
|
00db10 |
else
|
|
|
00db10 |
printf ("The end-of-file flag is cleared.\n");
|
|
|
00db10 |
|