13 if (sprintf (buf
, "%.0ls", L
"foo") != 0
16 puts ("sprintf (buf, \"%.0ls\", L\"foo\") produced some output");
20 #define SIZE (1024*70000)
23 char *dst
= malloc (SIZE
+ 1);
27 puts ("memory allocation failure");
32 sprintf (dst
, "%*s", SIZE
, "");
33 if (strnlen (dst
, SIZE
+ 1) != SIZE
)
35 puts ("sprintf (dst, \"%*s\", " STR(SIZE
) ", \"\") did not produce enough output");
41 if (sprintf (buf
, "%1$d%3$.*2$s%4$d", 7, 67108863, "x", 8) != 3
42 || strcmp (buf
, "7x8") != 0)
44 printf ("sprintf (buf, \"%%1$d%%3$.*2$s%%4$d\", 7, 67108863, \"x\", 8) produced `%s' output", buf
);
48 if (sprintf (buf
, "%67108863.16\"%d", 7) != 14
49 || strcmp (buf
, "%67108863.16\"7") != 0)
51 printf ("sprintf (buf, \"%%67108863.16\\\"%%d\", 7) produced `%s' output", buf
);
55 if (sprintf (buf
, "%*\"%d", 0x3ffffff, 7) != 11
56 || strcmp (buf
, "%67108863\"7") != 0)
58 printf ("sprintf (buf, \"%%*\\\"%%d\", 0x3ffffff, 7) produced `%s' output", buf
);
62 if (setlocale (LC_ALL
, "de_DE.UTF-8") == NULL
)
64 puts ("cannot set locale");
67 else if (sprintf (buf
, "%.8s\n", "Foo: \277") != 7
68 || strcmp (buf
, "Foo: \277\n") != 0)
70 printf ("sprintf (buf, \"%%.8s\\n\", \"Foo: \\277\") produced '%s' output\n", buf
);