g++ still cannot handled [restrict].
[glibc/history.git] / libio / bug-rewind2.c
blob51b574433029f835200f21eaab80a0f8f8fe7335
1 #include <stdio.h>
2 #include <wchar.h>
5 static int fd;
7 static void prepare (void);
8 #define PREPARE(argc, argv) prepare ()
11 #define TEST_FUNCTION do_test ()
12 static int do_test (void);
13 #include "../test-skeleton.c"
16 static void
17 prepare (void)
19 fd = create_temp_file ("wrewind2.", NULL);
20 if (fd == -1)
21 exit (3);
25 static int
26 do_test (void)
28 wchar_t dummy[10];
29 int ret = 0;
30 FILE *fp;
31 int result = 0;
33 fp = fdopen (fd, "w+");
34 if (fp == NULL)
36 puts ("fopen(""testfile"", ""w+"") returned NULL.");
37 return 1;
39 else
41 fwprintf (fp, L"abcd");
42 printf ("current pos = %ld\n", ftell (fp));
43 if (ftell (fp) != 4)
44 result = 1;
46 rewind (fp);
47 ret = fwscanf (fp, L"%c", dummy);
49 printf ("current pos = %ld\n", ftell (fp));
50 if (ftell (fp) != 1)
51 result = 1;
53 rewind (fp);
54 printf ("current pos = %ld\n", ftell (fp));
55 if (ftell (fp) != 0)
56 result = 1;
58 fclose (fp);
61 return result;