fix malloc-brk-fail
[libc-test] / src / functional / snprintf.c
index 600cd11..70c1118 100644 (file)
@@ -36,11 +36,11 @@ static const struct {
        { "%0-5d", 12, "12   " },
        { "%-05d", 12, "12   " },
 
-       /* ...explicit precision of 0 shall be no characters. */
+       /* ...explicit precision of 0 shall be no characters except for alt-octal. */
        { "%.0d", 0, "" },
        { "%.0o", 0, "" },
        { "%#.0d", 0, "" },
-       { "%#.0o", 0, "" },
+       { "%#.0o", 0, "0" },
        { "%#.0x", 0, "" },
 
        /* ...but it still has to honor width and flags. */
@@ -60,6 +60,20 @@ static const struct {
        { "%o", 15, "17" },
        { "%#o", 15, "017" },
 
+       /* octal: corner cases */
+       { "%#o", 0, "0" },
+       { "%#.0o", 0, "0" },
+       { "%#.1o", 0, "0" },
+       { "%#o", 1, "01" },
+       { "%#.0o", 1, "01" },
+       { "%#.1o", 1, "01" },
+       { "%#04o", 1, "0001" },
+       { "%#04.0o", 1, "  01" },
+       { "%#04.1o", 1, "  01" },
+       { "%04o", 1, "0001" },
+       { "%04.0o", 1, "   1" },
+       { "%04.1o", 1, "   1" },
+
        { NULL, 0.0, NULL }
 };