Back to index

glibc  2.9
bug19.c
Go to the documentation of this file.
00001 #include <assert.h>
00002 #include <errno.h>
00003 #include <stdio.h>
00004 
00005 #ifndef CHAR
00006 # define CHAR char
00007 # define L(str) str
00008 # define FPUTS fputs
00009 # define FSCANF fscanf
00010 #endif
00011 
00012 
00013 static int
00014 do_test (void)
00015 {
00016   FILE *fp = tmpfile ();
00017   if (fp == NULL)
00018     {
00019       puts ("cannot open file");
00020       return 1;
00021     }
00022 
00023   FPUTS (L("7-11"), fp);
00024   rewind (fp);
00025 
00026   printf("setting errno to EINTR\n");
00027   errno = EINTR;
00028 
00029   printf("checking sscanf\n");
00030 
00031   int i, j, n;
00032 
00033   i = j = n = 0;
00034   FSCANF (fp, L(" %i - %i %n"), &i, &j, &n);
00035   printf ("found %i-%i (length=%i)\n", i, j, n);
00036 
00037   int result = 0;
00038   if (i != 7)
00039     {
00040       printf ("i is %d, expected 7\n", i);
00041       result = 1;
00042     }
00043   if (j != 11)
00044     {
00045       printf ("j is %d, expected 11\n", j);
00046       result = 1;
00047     }
00048   if (n != 4)
00049     {
00050       printf ("n is %d, expected 4\n", j);
00051       result = 1;
00052     }
00053 
00054   return result;
00055 }
00056 
00057 #define TEST_FUNCTION do_test ()
00058 #include "../test-skeleton.c"