Move printf-related code to printf.cc
This commit is contained in:
parent
361911dd18
commit
d16582a038
@ -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)
|
||||
|
@ -26,7 +26,6 @@
|
||||
*/
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "fmt/printf.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -438,17 +437,6 @@ FMT_FUNC void vprint_colored(Color c, cstring_view format, args args) {
|
||||
std::fputs(RESET_COLOR, stdout);
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
void printf(basic_writer<Char> &w, basic_cstring_view<Char> 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<int>(size);
|
||||
}
|
||||
|
||||
#ifndef FMT_HEADER_ONLY
|
||||
|
||||
template struct internal::basic_data<void>;
|
||||
@ -459,8 +447,6 @@ template void basic_fixed_buffer<char>::grow(std::size_t);
|
||||
|
||||
template void internal::arg_map<context>::init(const args &args);
|
||||
|
||||
template void printf_context<char>::format(buffer &);
|
||||
|
||||
template int internal::char_traits<char>::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<wchar_t>::grow(std::size_t);
|
||||
|
||||
template void internal::arg_map<wcontext>::init(const wargs &args);
|
||||
|
||||
template void printf_context<wchar_t>::format(wbuffer &);
|
||||
|
||||
template int internal::char_traits<wchar_t>::format_float(
|
||||
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
||||
unsigned width, int precision, double value);
|
||||
|
20
fmt/printf.cc
Normal file
20
fmt/printf.cc
Normal file
@ -0,0 +1,20 @@
|
||||
#include "fmt/printf.h"
|
||||
|
||||
namespace fmt {
|
||||
|
||||
template <typename Char>
|
||||
void printf(basic_writer<Char> &w, basic_cstring_view<Char> 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<int>(size);
|
||||
}
|
||||
|
||||
#ifndef FMT_HEADER_ONLY
|
||||
template void printf_context<char>::format(buffer &);
|
||||
template void printf_context<wchar_t>::format(wbuffer &);
|
||||
#endif
|
||||
}
|
@ -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 <algorithm>
|
||||
#include <cstring>
|
||||
|
Loading…
Reference in New Issue
Block a user