1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include <config.h>
#define _GL_NO_LARGE_FILES
#include <stdio.h>
#include "signature.h"
SIGNATURE_CHECK (fseek, int, (FILE *, long, int));
#include "macros.h"
#ifndef FUNC_UNGETC_BROKEN
# define FUNC_UNGETC_BROKEN 0
#endif
int
main (int argc, char **argv)
{
int expected = argc > 1 ? 0 : -1;
ASSERT (fseek (stdin, 0, SEEK_CUR) == expected);
if (argc > 1)
{
int ch = fgetc (stdin);
ASSERT (ch == '#');
ASSERT (ungetc (ch, stdin) == ch);
ASSERT (fseek (stdin, 2, SEEK_SET) == 0);
ch = fgetc (stdin);
ASSERT (ch == '/');
if (2 < argc)
{
if (FUNC_UNGETC_BROKEN)
{
fputs ("Skipping test: ungetc cannot handle arbitrary bytes\n",
stderr);
return 77;
}
ASSERT (ungetc (ch ^ 0xff, stdin) == (ch ^ 0xff));
}
ASSERT (fseek (stdin, 0, SEEK_END) == 0);
ASSERT (fgetc (stdin) == EOF);
ASSERT (feof (stdin));
ASSERT (fseek (stdin, 0, SEEK_END) == 0);
ASSERT (!feof (stdin));
}
return 0;
}
|