(root)/
glibc-2.38/
stdio-common/
bug18.c
       1  #include <assert.h>
       2  #include <errno.h>
       3  #include <stdio.h>
       4  
       5  #ifndef CHAR
       6  # define CHAR char
       7  # define L(str) str
       8  # define SSCANF sscanf
       9  #endif
      10  
      11  
      12  static int
      13  do_test (void)
      14  {
      15    printf("setting errno to EINTR\n");
      16    errno = EINTR;
      17  
      18    printf("checking sscanf\n");
      19  
      20    CHAR str[] = L("7-11");
      21    int i, j, n;
      22  
      23    i = j = n = 0;
      24    SSCANF (str, L(" %i - %i %n"), &i, &j, &n);
      25    printf ("found %i-%i (length=%i)\n", i, j, n);
      26  
      27    int result = 0;
      28    if (i != 7)
      29      {
      30        printf ("i is %d, expected 7\n", i);
      31        result = 1;
      32      }
      33    if (j != 11)
      34      {
      35        printf ("j is %d, expected 11\n", j);
      36        result = 1;
      37      }
      38    if (n != 4)
      39      {
      40        printf ("n is %d, expected 4\n", j);
      41        result = 1;
      42      }
      43  
      44    return result;
      45  }
      46  
      47  #define TEST_FUNCTION do_test ()
      48  #include "../test-skeleton.c"