Back to index

glibc  2.9
bug18.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 SSCANF sscanf
00009 #endif
00010 
00011 
00012 static int
00013 do_test (void)
00014 {
00015   printf("setting errno to EINTR\n");
00016   errno = EINTR;
00017 
00018   printf("checking sscanf\n");
00019 
00020   CHAR str[] = L("7-11");
00021   int i, j, n;
00022 
00023   i = j = n = 0;
00024   SSCANF (str, L(" %i - %i %n"), &i, &j, &n);
00025   printf ("found %i-%i (length=%i)\n", i, j, n);
00026 
00027   int result = 0;
00028   if (i != 7)
00029     {
00030       printf ("i is %d, expected 7\n", i);
00031       result = 1;
00032     }
00033   if (j != 11)
00034     {
00035       printf ("j is %d, expected 11\n", j);
00036       result = 1;
00037     }
00038   if (n != 4)
00039     {
00040       printf ("n is %d, expected 4\n", j);
00041       result = 1;
00042     }
00043 
00044   return result;
00045 }
00046 
00047 #define TEST_FUNCTION do_test ()
00048 #include "../test-skeleton.c"