X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Ffunctional%2Fsnprintf.c;h=70c111803e071e44ebfa73ccb228aed32268457e;hb=281b80f0e70fe28356c3f0ded8b86f28a5c74d0a;hp=2c94d02b69d8240d64d44bc37640201c31fd4656;hpb=cfa23cc1bd01f5c44d7746b8b1839f84d5e1b6eb;p=libc-test diff --git a/src/functional/snprintf.c b/src/functional/snprintf.c index 2c94d02..70c1118 100644 --- a/src/functional/snprintf.c +++ b/src/functional/snprintf.c @@ -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 } }; @@ -86,7 +100,8 @@ static const struct { { "%f", 1.3, "1.300000" }, { "%f", 1.4, "1.400000" }, { "%f", 1.5, "1.500000" }, - { "%.4f", 1.06125, "1.0612" }, + { "%.4f", 1.06125, "1.0613" }, /* input is not representible exactly as double */ + { "%.4f", 1.03125, "1.0312" }, /* 0x1.08p0 */ { "%.2f", 1.375, "1.38" }, { "%.1f", 1.375, "1.4" }, { "%.1lf", 1.375, "1.4" },