diff --git a/fmt/CMakeLists.txt b/fmt/CMakeLists.txt index 5a96c412..c6502a3d 100644 --- a/fmt/CMakeLists.txt +++ b/fmt/CMakeLists.txt @@ -1,6 +1,6 @@ # Define the fmt library, its includes and the needed defines. # format.cc is added to FMT_HEADERS for the header-only configuration. -set(FMT_HEADERS format.h format.cc ostream.h ostream.cc printf.h +set(FMT_HEADERS format.h format.cc ostream.h ostream.cc printf.h printf.cc string.h time.h) if (HAVE_OPEN) set(FMT_HEADERS ${FMT_HEADERS} posix.h) diff --git a/fmt/format.cc b/fmt/format.cc index f8cd4c54..1647664f 100644 --- a/fmt/format.cc +++ b/fmt/format.cc @@ -26,7 +26,6 @@ */ #include "fmt/format.h" -#include "fmt/printf.h" #include @@ -438,17 +437,6 @@ FMT_FUNC void vprint_colored(Color c, cstring_view format, args args) { std::fputs(RESET_COLOR, stdout); } -template -void printf(basic_writer &w, basic_cstring_view format, args args); - -FMT_FUNC int vfprintf(std::FILE *f, cstring_view format, printf_args args) { - memory_buffer buffer; - printf(buffer, format, args); - std::size_t size = buffer.size(); - return std::fwrite( - buffer.data(), 1, size, f) < size ? -1 : static_cast(size); -} - #ifndef FMT_HEADER_ONLY template struct internal::basic_data; @@ -459,8 +447,6 @@ template void basic_fixed_buffer::grow(std::size_t); template void internal::arg_map::init(const args &args); -template void printf_context::format(buffer &); - template int internal::char_traits::format_float( char *buffer, std::size_t size, const char *format, unsigned width, int precision, double value); @@ -477,8 +463,6 @@ template void basic_fixed_buffer::grow(std::size_t); template void internal::arg_map::init(const wargs &args); -template void printf_context::format(wbuffer &); - template int internal::char_traits::format_float( wchar_t *buffer, std::size_t size, const wchar_t *format, unsigned width, int precision, double value); diff --git a/fmt/printf.cc b/fmt/printf.cc new file mode 100644 index 00000000..13e4ed82 --- /dev/null +++ b/fmt/printf.cc @@ -0,0 +1,20 @@ +#include "fmt/printf.h" + +namespace fmt { + +template +void printf(basic_writer &w, basic_cstring_view format, args args); + +FMT_FUNC int vfprintf(std::FILE *f, cstring_view format, printf_args args) { + memory_buffer buffer; + printf(buffer, format, args); + std::size_t size = buffer.size(); + return std::fwrite( + buffer.data(), 1, size, f) < size ? -1 : static_cast(size); +} + +#ifndef FMT_HEADER_ONLY +template void printf_context::format(buffer &); +template void printf_context::format(wbuffer &); +#endif +} diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index fbe6d4f7..637f6225 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -30,6 +30,7 @@ // Include format.cc instead of format.h to test implementation-specific stuff. #include "fmt/format.cc" +#include "fmt/printf.cc" #include #include