2002-07-16 07:37:22 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
#define PASSED 0
|
|
|
|
#define FAILED 3
|
|
|
|
|
|
|
|
|
2002-08-26 16:08:50 +08:00
|
|
|
static int fd;
|
|
|
|
|
|
|
|
static void prepare (void);
|
|
|
|
#define PREPARE(argc, argv) prepare ()
|
|
|
|
|
|
|
|
|
2002-07-23 06:25:20 +08:00
|
|
|
#define TEST_FUNCTION do_test ()
|
|
|
|
static int do_test (void);
|
|
|
|
#include "../test-skeleton.c"
|
|
|
|
|
|
|
|
|
2002-08-26 16:08:50 +08:00
|
|
|
static void
|
|
|
|
prepare (void)
|
|
|
|
{
|
|
|
|
fd = create_temp_file ("wrewind.", NULL);
|
|
|
|
if (fd == -1)
|
|
|
|
exit (3);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-23 06:25:20 +08:00
|
|
|
static int
|
|
|
|
do_test (void)
|
2002-07-16 07:37:22 +08:00
|
|
|
{
|
|
|
|
FILE *fptr;
|
|
|
|
char arg1;
|
|
|
|
char arg2;
|
2002-07-23 06:25:20 +08:00
|
|
|
int ret1, ret2, result, num;
|
2002-07-16 07:37:22 +08:00
|
|
|
|
|
|
|
ret1 = 0;
|
|
|
|
ret2 = 0;
|
|
|
|
|
2002-07-23 06:25:20 +08:00
|
|
|
fptr = fdopen (fd, "w+");
|
|
|
|
if (fptr == NULL)
|
2002-07-16 07:37:22 +08:00
|
|
|
{
|
|
|
|
printf ("Unable to open file.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-07-23 06:25:20 +08:00
|
|
|
if (fwprintf (fptr, L"cderf") <= 0)
|
2002-07-16 07:37:22 +08:00
|
|
|
{
|
|
|
|
printf ("Unable to write to file with fwprintf().\n");
|
|
|
|
fclose (fptr);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
rewind (fptr);
|
|
|
|
ret1 = fwscanf (fptr, L"%c%c", &arg1, &arg2);
|
|
|
|
|
|
|
|
rewind (fptr);
|
|
|
|
ret2 = fwscanf (fptr, L"%c%n%c", &arg1, &num, &arg2);
|
|
|
|
|
|
|
|
if (arg2 != 'd')
|
|
|
|
{
|
|
|
|
result = FAILED;
|
|
|
|
printf ("rewind after first fwscanf failed\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
printf ("Passed\n");
|
|
|
|
result = PASSED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fclose (fptr);
|
|
|
|
return result;
|
|
|
|
}
|