From 018d8b57f6ff76fc5bb5abaa243ff3f805bf297f Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 30 Mar 2019 20:20:26 -0700 Subject: [PATCH] Remove broken snprintf --- include/fmt/printf.h | 47 -------------------------------------------- test/printf-test.cc | 20 ------------------- 2 files changed, 67 deletions(-) diff --git a/include/fmt/printf.h b/include/fmt/printf.h index e540a55b..50a3de48 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -584,14 +584,6 @@ typedef basic_printf_context_t::type wprintf_context; typedef basic_format_args printf_args; typedef basic_format_args wprintf_args; -template -struct basic_printf_n_context_t { - typedef fmt::internal::truncating_iterator OutputIter; - typedef output_range Range; - typedef basic_printf_context> - type; -}; - /** \rst Constructs an `~fmt::format_arg_store` object that contains references to @@ -627,17 +619,6 @@ inline std::basic_string vsprintf( return to_string(buffer); } -template ::value)> -inline format_to_n_result vsnprintf( - OutputIt out, std::size_t n, const S& format, - basic_format_args::type> - args) { - typedef internal::truncating_iterator It; - auto it = printf(It(out, n), to_string_view(format), args); - return {it.base(), it.count()}; -} - /** \rst Formats arguments and returns the result as a string. @@ -658,34 +639,6 @@ inline std::basic_string sprintf(const S& format, return vsprintf(to_string_view(format), basic_format_args(as)); } -/** - \rst - Formats arguments for up to ``n`` characters stored through output iterator - ``out``. The function returns the updated iterator and the untruncated amount - of characters. - - **Example**:: - std::vector out; - - typedef fmt::format_to_n_result< - std::back_insert_iterator>> res; - res Res = fmt::snprintf(std::back_inserter(out), 5, "The answer is %d", 42); - \endrst -*/ -template ::value&& - internal::is_output_iterator::value)> -inline format_to_n_result snprintf(OutputIt out, std::size_t n, - const S& format, - const Args&... args) { - internal::check_format_string(format); - typedef FMT_CHAR(S) Char; - typedef typename basic_printf_n_context_t::type context; - format_arg_store as{args...}; - return vsnprintf(out, n, to_string_view(format), - basic_format_args(as)); -} - template inline int vfprintf( std::FILE* f, const S& format, diff --git a/test/printf-test.cc b/test/printf-test.cc index d5f14a98..d669fdd1 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -554,23 +554,3 @@ TEST(PrintfTest, VSPrintfMakeWArgsExample) { fmt::make_wprintf_args(42, L"something"))); #endif } - -TEST(PrintfTest, snprintf) { - char buffer[4] = "xxx"; - auto result = fmt::snprintf(buffer, 0, "test"); - EXPECT_EQ("xxx", fmt::to_string_view(buffer)); - EXPECT_EQ(4u, result.size); - EXPECT_EQ(buffer, result.out); - result = fmt::snprintf(buffer, 2, "test"); - EXPECT_EQ("tex", fmt::to_string_view(buffer)); - EXPECT_EQ(4u, result.size); - EXPECT_EQ(buffer + 2, result.out); - result = fmt::snprintf(buffer, 3, "test"); - EXPECT_EQ("tes", fmt::to_string_view(buffer)); - EXPECT_EQ(4u, result.size); - EXPECT_EQ(buffer + 3, result.out); - result = fmt::snprintf(buffer, 4, "test"); - EXPECT_EQ("test", std::string(buffer, 4)); - EXPECT_EQ(4u, result.size); - EXPECT_EQ(buffer + 4, result.out); -}