NEWS update for closing 14815.
[glibc.git] / libio / bug-ftell.c
blob496c8cb75c4bcea92aff2afc840cd77545717cda
1 #include <locale.h>
2 #include <stdio.h>
3 #include <wchar.h>
4 #include <sys/types.h>
7 static int
8 do_test (void)
10 if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
12 puts ("setlocale failed");
13 return 1;
16 FILE *fp = tmpfile ();
17 if (fp == NULL)
19 puts ("tmpfile failed");
20 return 1;
23 if (fputws (L"hello", fp) == EOF)
25 puts ("fputws failed");
26 return 1;
29 rewind (fp);
31 const wchar_t *cp;
32 unsigned int cnt;
33 for (cp = L"hello", cnt = 1; *cp != L'\0'; ++cp, ++cnt)
35 wint_t wc = fgetwc (fp);
36 if (wc != (wint_t) *cp)
38 printf ("fgetwc failed: got L'%lc', expected L'%lc'\n",
39 wc, (wint_t) *cp);
40 return 1;
42 off_t o = ftello (fp);
43 if (o != cnt)
45 printf ("ftello failed: got %lu, expected %u\n",
46 (unsigned long int) o, cnt);
47 return 1;
49 printf ("round %u OK\n", cnt);
52 fclose (fp);
54 return 0;
57 #define TEST_FUNCTION do_test ()
58 #include "../test-skeleton.c"