1 #define _XOPEN_SOURCE 500
7 const char write_chars
[] = "ABC"; /* Characters on testfile. */
8 const wint_t unget_wchar
= L
'A'; /* Ungotten wide character. */
13 static int do_test (void);
14 #define TEST_FUNCTION do_test ()
16 #include "../test-skeleton.c"
26 fname
= (char *) malloc (strlen (test_dir
) + sizeof "/bug-ungetwc1.XXXXXX");
32 strcpy (stpcpy (fname
, test_dir
), "/bug-ungetwc1.XXXXXX");
36 printf ("cannot open temporary file: %m\n");
39 add_temp_file (fname
);
41 setlocale(LC_ALL
, "");
43 /* Output to the file. */
44 if ((fp
= fdopen (fd
, "w")) == NULL
)
46 fprintf (stderr
, "Cannot make `%s' file\n", fname
);
50 fprintf (fp
, "%s", write_chars
);
53 /* Read from the file. */
54 fp
= fopen (fname
, "r");
58 printf ("\nThe end-of-file indicator is set.\n");
60 /* Unget a wide character. */
61 ungetwc (unget_wchar
, fp
);
62 printf ("< `%lc' is ungotten.\n", unget_wchar
);
64 /* Check the end-of-file indicator. */
66 printf ("The end-of-file indicator is still set.\n");
68 printf ("The end-of-file flag is cleared.\n");