From 79209598f5c06808a83957b8876cf21f8fa12996 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 7 Jul 2019 06:54:25 -0700 Subject: [PATCH] core_format_specs -> sprintf_specs --- include/fmt/format-inl.h | 2 +- include/fmt/format.h | 66 ++++++++++++++++++++-------------------- src/format.cc | 4 +-- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index dd3ccb4f..0b463131 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -754,7 +754,7 @@ FMT_API bool grisu_format(Double value, buffer& buf, int precision, template char* sprintf_format(Double value, internal::buffer& buf, - core_format_specs specs) { + sprintf_specs specs) { // Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail. FMT_ASSERT(buf.capacity() != 0, "empty buffer"); diff --git a/include/fmt/format.h b/include/fmt/format.h index 02458d76..116fc539 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -954,38 +954,6 @@ using format_specs = basic_format_specs; namespace internal { -struct core_format_specs { - int precision; - char type; - bool alt : 1; - - template - constexpr core_format_specs(basic_format_specs specs) - : precision(specs.precision), type(specs.type), alt(specs.alt) {} - - constexpr bool has_precision() const { return precision >= 0; } -}; - -namespace grisu_options { -enum { fixed = 1, grisu3 = 2 }; -} - -// Formats value using the Grisu algorithm: -// https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf -template -FMT_API bool grisu_format(Double, buffer&, int, unsigned, int&); -template -inline bool grisu_format(Double, buffer&, int, unsigned, int&) { - return false; -} - -struct gen_digits_params { - int num_digits; - bool fixed; - bool upper; - bool trailing_zeros; -}; - // Writes the exponent exp in the form "[+-]d{2,3}" to buffer. template It write_exponent(int exp, It it) { FMT_ASSERT(-1000 < exp && exp < 1000, "exponent out of range"); @@ -1009,6 +977,13 @@ template It write_exponent(int exp, It it) { return it; } +struct gen_digits_params { + int num_digits; + bool fixed; + bool upper; + bool trailing_zeros; +}; + // The number is given as v = digits * pow(10, exp). template It grisu_prettify(const char* digits, int size, int exp, It it, @@ -1072,8 +1047,33 @@ It grisu_prettify(const char* digits, int size, int exp, It it, return it; } +namespace grisu_options { +enum { fixed = 1, grisu3 = 2 }; +} + +// Formats value using the Grisu algorithm: +// https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf +template +FMT_API bool grisu_format(Double, buffer&, int, unsigned, int&); +template +inline bool grisu_format(Double, buffer&, int, unsigned, int&) { + return false; +} + +struct sprintf_specs { + int precision; + char type; + bool alt : 1; + + template + constexpr sprintf_specs(basic_format_specs specs) + : precision(specs.precision), type(specs.type), alt(specs.alt) {} + + constexpr bool has_precision() const { return precision >= 0; } +}; + template -char* sprintf_format(Double, internal::buffer&, core_format_specs); +char* sprintf_format(Double, internal::buffer&, sprintf_specs); template FMT_CONSTEXPR void handle_int_type_spec(char spec, Handler&& handler) { diff --git a/src/format.cc b/src/format.cc index 8e73d31b..41076f16 100644 --- a/src/format.cc +++ b/src/format.cc @@ -36,10 +36,10 @@ template FMT_API format_context::iterator internal::vformat_to( internal::buffer&, string_view, basic_format_args); template FMT_API char* internal::sprintf_format(double, internal::buffer&, - core_format_specs); + sprintf_specs); template FMT_API char* internal::sprintf_format(long double, internal::buffer&, - core_format_specs); + sprintf_specs); // Explicit instantiations for wchar_t.