Upgrade to current vfprintf.

This gets us various bug fixes and missing C99 functionality.

Bug: https://code.google.com/p/android/issues/detail?id=64886
Change-Id: Ie9f8ac569e9b5eec1e4a1faacfe2c21662eaf895
This commit is contained in:
Elliott Hughes
2014-04-17 17:30:03 -07:00
parent 8da69a25b7
commit 0549371bd7
8 changed files with 650 additions and 263 deletions

View File

@@ -23,6 +23,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <wchar.h>
TEST(stdio, tmpfile_fileno_fprintf_rewind_fgets) {
FILE* fp = tmpfile();
@@ -192,18 +193,38 @@ TEST(stdio, printf_ssize_t) {
snprintf(buf, sizeof(buf), "%zd", v);
}
TEST(stdio, snprintf_n_format_specifier_not_implemented) {
#if defined(__BIONIC__)
// https://code.google.com/p/android/issues/detail?id=64886
TEST(stdio, snprintf_a) {
char buf[BUFSIZ];
EXPECT_EQ(23, snprintf(buf, sizeof(buf), "<%a>", 9990.235));
EXPECT_STREQ("<0x1.3831e147ae148p+13>", buf);
}
TEST(stdio, snprintf_lc) {
char buf[BUFSIZ];
wint_t wc = L'a';
EXPECT_EQ(3, snprintf(buf, sizeof(buf), "<%lc>", wc));
EXPECT_STREQ("<a>", buf);
}
TEST(stdio, snprintf_ls) {
char buf[BUFSIZ];
wchar_t* ws = NULL;
EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%ls>", ws));
EXPECT_STREQ("<(null)>", buf);
wchar_t chars[] = { L'h', L'i', 0 };
ws = chars;
EXPECT_EQ(4, snprintf(buf, sizeof(buf), "<%ls>", ws));
EXPECT_STREQ("<hi>", buf);
}
TEST(stdio, snprintf_n) {
char buf[32];
int i = 0;
// We deliberately don't implement %n, so it's treated like
// any other unrecognized format specifier.
EXPECT_EQ(5, snprintf(buf, sizeof(buf), "a %n b", &i));
EXPECT_EQ(0, i);
EXPECT_STREQ("a n b", buf);
#else // __BIONIC__
GTEST_LOG_(INFO) << "This test does nothing.\n";
#endif // __BIONIC__
EXPECT_EQ(4, snprintf(buf, sizeof(buf), "a %n b", &i));
EXPECT_EQ(2, i);
EXPECT_STREQ("a b", buf);
}
TEST(stdio, snprintf_smoke) {