1 /* Taken from the Li18nux base test suite. */
3 #define _XOPEN_SOURCE 500
15 const char *str
= "abcdef";
16 wint_t ret
, wc
, ungetone
= 0x00E4; /* 0x00E4 means `a umlaut'. */
17 char fname
[] = "/tmp/tst-ungetwc1.out.XXXXXX";
21 puts("This program runs on de_DE.UTF-8 locale.");
22 if (setlocale(LC_ALL
, "de_DE.UTF-8") == NULL
) {
23 fprintf(stderr
, "Err: Cannot run on the de_DE.UTF-8 locale");
29 printf("cannot open temp file: %m\n");
33 /* Write some characters to `testfile'. */
34 if ((fp
= fdopen(fd
, "w")) == NULL
) {
35 fprintf(stderr
, "Cannot open 'testfile'.");
41 /* Open `testfile'. */
42 if ((fp
= fopen(fname
, "r")) == NULL
) {
43 fprintf(stderr
, "Cannot open 'testfile'.");
47 /* Unget a character. */
48 ret
= ungetwc(ungetone
, fp
);
49 printf("Unget a character (0x%04x)\n", (unsigned int) ungetone
);
52 puts("ungetwc() returns NULL.");
56 /* Reget a character. */
58 printf("Reget a character (0x%04x)\n", (unsigned int) wc
);
61 puts("The ungotten character is equal to the regotten character.");
64 puts("The ungotten character is not equal to the regotten character.");
65 printf("ungotten one: %04x, regetone: %04x", ungetone
, wc
);