1 /* Taken from the Li18nux base test suite. */
3 #define _XOPEN_SOURCE 500
14 const char *str
= "abcdef";
15 wint_t ret
, wc
, ungetone
= 0x00E4; /* 0x00E4 means `a umlaut'. */
16 char fname
[] = "/tmp/tst-ungetwc1.out.XXXXXX";
20 puts ("This program runs on de_DE.UTF-8 locale.");
21 if (setlocale (LC_ALL
, "de_DE.UTF-8") == NULL
)
23 fprintf (stderr
, "Err: Cannot run on the de_DE.UTF-8 locale");
30 printf ("cannot open temp file: %m\n");
34 /* Write some characters to `testfile'. */
35 if ((fp
= fdopen (fd
, "w")) == NULL
)
37 fprintf (stderr
, "Cannot open 'testfile'.");
43 /* Open `testfile'. */
44 if ((fp
= fopen (fname
, "r")) == NULL
)
46 fprintf (stderr
, "Cannot open 'testfile'.");
50 /* Unget a character. */
51 ret
= ungetwc (ungetone
, fp
);
52 printf ("Unget a character (0x%04x)\n", (unsigned int) ungetone
);
56 puts ("ungetwc() returns NULL.");
60 /* Reget a character. */
62 printf ("Reget a character (0x%04x)\n", (unsigned int) wc
);
66 puts ("The ungotten character is equal to the regotten character.");
71 puts ("The ungotten character is not equal to the regotten character.");
72 printf ("ungotten one: %04x, regetone: %04x", ungetone
, wc
);
83 #define TEST_FUNCTION do_test ()
84 #include "../test-skeleton.c"