(lr_token): Remove duplicate handling of EOF.
[glibc/history.git] / libio / bug-rewind.c
blob4f8242df3d6d1f75fe8ba98dbeb400a946baa9ec
1 #include <stdio.h>
2 #include <wchar.h>
4 #define PASSED 0
5 #define FAILED 3
8 static int fd;
10 static void prepare (void);
11 #define PREPARE(argc, argv) prepare ()
14 #define TEST_FUNCTION do_test ()
15 static int do_test (void);
16 #include "../test-skeleton.c"
19 static void
20 prepare (void)
22 fd = create_temp_file ("wrewind.", NULL);
23 if (fd == -1)
24 exit (3);
28 static int
29 do_test (void)
31 FILE *fptr;
32 char arg1;
33 char arg2;
34 int ret1, ret2, result, num;
36 ret1 = 0;
37 ret2 = 0;
39 fptr = fdopen (fd, "w+");
40 if (fptr == NULL)
42 printf ("Unable to open file.\n");
43 return 1;
46 if (fwprintf (fptr, L"cderf") <= 0)
48 printf ("Unable to write to file with fwprintf().\n");
49 fclose (fptr);
50 return 2;
53 rewind (fptr);
54 ret1 = fwscanf (fptr, L"%c%c", &arg1, &arg2);
56 rewind (fptr);
57 ret2 = fwscanf (fptr, L"%c%n%c", &arg1, &num, &arg2);
59 if (arg2 != 'd')
61 result = FAILED;
62 printf ("rewind after first fwscanf failed\n");
64 else
66 printf ("Passed\n");
67 result = PASSED;
71 fclose (fptr);
72 return result;