diff --git a/fmt/printf.h b/fmt/printf.h index f695d1aa..a41d61ba 100644 --- a/fmt/printf.h +++ b/fmt/printf.h @@ -74,7 +74,7 @@ class DefaultType : public ArgVisitor { wchar_t visit_any_int(T) { return 'd'; } template - wchar_t visit_any_double(T) { return 'f'; } + wchar_t visit_any_double(T) { return 'g'; } wchar_t visit_unhandled_arg() { return 's'; } }; @@ -119,7 +119,7 @@ class ArgConverter : public ArgVisitor, void> { void visit_any_int(U value) { bool is_signed = type_ == 'd' || type_ == 'i'; if (type_ == 's') { - is_signed = std::numeric_limits::is_signed; + is_signed = std::numeric_limits::is_signed; } using internal::Arg; @@ -492,8 +492,8 @@ void PrintfFormatter::format(BasicCStringRef format_str) { spec.type_ = static_cast(*s++); if (spec.type_ == 's') { - // set the format type to the default if 's' is specified - spec.type_ = internal::DefaultType().visit(arg); + // set the format type to the default if 's' is specified + spec.type_ = internal::DefaultType().visit(arg); } if (arg.type <= Arg::LAST_INTEGER_TYPE) { diff --git a/test/printf-test.cc b/test/printf-test.cc index 2d818683..4d8dc756 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -402,7 +402,7 @@ TEST(PrintfTest, LongLong) { TEST(PrintfTest, Float) { EXPECT_PRINTF("392.650000", "%f", 392.65); EXPECT_PRINTF("392.650000", "%F", 392.65); - EXPECT_PRINTF("392.650000", "%s", 392.65); + EXPECT_PRINTF("392.65", "%s", 392.65); char buffer[BUFFER_SIZE]; safe_sprintf(buffer, "%e", 392.65); EXPECT_PRINTF(buffer, "%e", 392.65);