2 #define _XOPEN_SOURCE 600
5 /* The following macro definitions are a hack. They word around disabling
6 the GNU extension while still using a few internal headers. */
7 #define u_char unsigned char
8 #define u_short unsigned short
9 #define u_int unsigned int
10 #define u_long unsigned long
19 printf ("test at line %d failed\n", __LINE__); \
30 if (sscanf (" 0.25s x", "%e%3c", &f
, c
) != 2)
32 else if (f
!= 0.25 || memcmp (c
, "s x", 3) != 0)
34 if (sscanf (" 1.25s x", "%as%2c", &f
, c
) != 2)
36 else if (f
!= 1.25 || memcmp (c
, " x", 2) != 0)
38 if (sscanf (" 2.25s x", "%las%2c", &d
, c
) != 2)
40 else if (d
!= 2.25 || memcmp (c
, " x", 2) != 0)
42 if (sscanf (" 3.25S x", "%4aS%2c", &f
, c
) != 2)
44 else if (f
!= 3.25 || memcmp (c
, " x", 2) != 0)
46 if (sscanf (" 4.25[0-9.] x", "%a[0-9.]%2c", &f
, c
) != 2)
48 else if (f
!= 4.25 || memcmp (c
, " x", 2) != 0)
50 if (sscanf (" 5.25[0-9.] x", "%la[0-9.]%2c", &d
, c
) != 2)
52 else if (d
!= 5.25 || memcmp (c
, " x", 2) != 0)
55 const char *tmpdir
= getenv ("TMPDIR");
56 if (tmpdir
== NULL
|| tmpdir
[0] == '\0')
59 char fname
[strlen (tmpdir
) + sizeof "/tst-scanf15.XXXXXX"];
60 sprintf (fname
, "%s/tst-scanf15.XXXXXX", tmpdir
);
64 /* Create a temporary file. */
65 int fd
= mkstemp (fname
);
69 FILE *fp
= fdopen (fd
, "w+");
74 if (fputs (" 1.25s x", fp
) == EOF
)
76 if (fseek (fp
, 0, SEEK_SET
) != 0)
78 if (fscanf (fp
, "%as%2c", &f
, c
) != 2)
80 else if (f
!= 1.25 || memcmp (c
, " x", 2) != 0)
83 if (freopen (fname
, "r", stdin
) == NULL
)
87 if (scanf ("%as%2c", &f
, c
) != 2)
89 else if (f
!= 1.25 || memcmp (c
, " x", 2) != 0)