1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 
6 static const char expected[] = "\
7 \n\
8 a\n\
9 abbcd55\
10 \n\
11 a\n\
12 abbcd55\
13 \n\
14 a\n\
15 abbcd55\
16 \n\
17 a\n\
18 abbcd55\
19 \n\
20 a\n\
21 abbcd55\
22 \n\
23 a\n\
24 abbcd55\
25 \n\
26 a\n\
27 abbcd55\
28 \n\
29 a\n\
30 abbcd55\
31 \n\
32 a\n\
33 abbcd55\
34 \n\
35 a\n\
36 abbcd55\
37 \n\
38 a\n\
39 abbcd55\
40 \n\
41 a\n\
42 abbcd55\
43 \n\
44 a\n\
45 abbcd55%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
46 
47 static int
do_test(void)48 do_test (void)
49 {
50   char *buf = malloc (strlen (expected) + 1);
51   snprintf (buf, strlen (expected) + 1,
52 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
53 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
54 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
55 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
56 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
57 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
58 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
59 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
60 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
61 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
62 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
63 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
64 	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
65 	    "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",
66 	    "a", "b", "c", "d", 5);
67   return strcmp (buf, expected) != 0;
68 }
69 
70 #define TEST_FUNCTION do_test ()
71 #include "../test-skeleton.c"
72