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