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