aboutsummaryrefslogtreecommitdiff
path: root/libio/bug-ungetwc1.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /libio/bug-ungetwc1.c
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.gz
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.bz2
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.zip
Prepare for radical source tree reorganization.zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage directory, REORG.TODO, except for files that will certainly still exist in their current form at top level when we're done (COPYING, COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which are moved to the new directory OldChangeLogs, instead), and the generated file INSTALL (which is just deleted; in the new order, there will be no generated files checked into version control).
Diffstat (limited to 'libio/bug-ungetwc1.c')
-rw-r--r--libio/bug-ungetwc1.c91
1 files changed, 0 insertions, 91 deletions
diff --git a/libio/bug-ungetwc1.c b/libio/bug-ungetwc1.c
deleted file mode 100644
index 56a3d336ae..0000000000
--- a/libio/bug-ungetwc1.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#define _XOPEN_SOURCE 500
-#include <stdio.h>
-#include <stdlib.h>
-#include <locale.h>
-#include <wchar.h>
-
-const char write_chars[] = "ABC"; /* Characters on testfile. */
-const wint_t unget_wchar = L'A'; /* Ungotten wide character. */
-
-char *fname;
-
-
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-
-#include "../test-skeleton.c"
-
-
-static int
-do_test (void)
-{
- wint_t wc;
- FILE *fp;
- int fd;
-
- fname = (char *) malloc (strlen (test_dir) + sizeof "/bug-ungetwc1.XXXXXX");
- if (fname == NULL)
- {
- puts ("no memory");
- return 1;
- }
- strcpy (stpcpy (fname, test_dir), "/bug-ungetwc1.XXXXXX");
- fd = mkstemp (fname);
- if (fd == -1)
- {
- printf ("cannot open temporary file: %m\n");
- return 1;
- }
- add_temp_file (fname);
-
- setlocale(LC_ALL, "");
-
- /* Output to the file. */
- if ((fp = fdopen (fd, "w")) == NULL)
- {
- fprintf (stderr, "Cannot make `%s' file\n", fname);
- exit (EXIT_FAILURE);
- }
-
- fprintf (fp, "%s", write_chars);
- fclose (fp);
-
- /* Read from the file. */
- fp = fopen (fname, "r");
-
- size_t i = 0;
- while (!feof (fp))
- {
- wc = getwc (fp);
- if (i >= sizeof (write_chars))
- {
- printf ("Did not get end-of-file when expected.\n");
- return 1;
- }
- else if (wc != (write_chars[i] ? write_chars[i] : WEOF))
- {
- printf ("Unexpected %lu from getwc.\n", (unsigned long int) wc);
- return 1;
- }
- i++;
- }
- printf ("\nThe end-of-file indicator is set.\n");
-
- /* Unget a wide character. */
- ungetwc (unget_wchar, fp);
- printf ("< `%lc' is ungotten.\n", unget_wchar);
-
- /* Check the end-of-file indicator. */
- if (feof (fp))
- {
- printf ("The end-of-file indicator is still set.\n");
- return 1;
- }
- else
- printf ("The end-of-file flag is cleared.\n");
-
- fflush (stdout);
- fclose (fp);
-
- return 0;
-}