Add a define to force the use of fallback_file

This commit is contained in:
Matt Stafford 2024-06-06 13:03:49 +10:00 committed by Victor Zverovich
parent 18a9676d95
commit 2c0d9e9409
2 changed files with 13 additions and 4 deletions

View File

@ -1600,14 +1600,21 @@ template <typename F> class fallback_file : public file_base<F> {
}
};
template <typename F, FMT_ENABLE_IF(sizeof(F::_p) != 0)>
#ifndef FMT_USE_FALLBACK_FILE
# define FMT_USE_FALLBACK_FILE 1
#endif
template <typename F,
FMT_ENABLE_IF(sizeof(F::_p) != 0 && !FMT_USE_FALLBACK_FILE)>
auto get_file(F* f, int) -> apple_file<F> {
return f;
}
template <typename F, FMT_ENABLE_IF(sizeof(F::_IO_read_ptr) != 0)>
template <typename F,
FMT_ENABLE_IF(sizeof(F::_IO_read_ptr) != 0 && !FMT_USE_FALLBACK_FILE)>
inline auto get_file(F* f, int) -> glibc_file<F> {
return f;
}
inline auto get_file(FILE* f, ...) -> fallback_file<FILE> { return f; }
using file_ref = decltype(get_file(static_cast<FILE*>(nullptr), 0));

View File

@ -153,11 +153,13 @@ class string_scan_buffer final : public scan_buffer {
class file_scan_buffer final : public scan_buffer {
private:
template <typename F, FMT_ENABLE_IF(sizeof(F::_IO_read_ptr) != 0)>
template <typename F, FMT_ENABLE_IF(sizeof(F::_IO_read_ptr) != 0 &&
!FMT_USE_FALLBACK_FILE)>
static auto get_file(F* f, int) -> glibc_file<F> {
return f;
}
template <typename F, FMT_ENABLE_IF(sizeof(F::_p) != 0)>
template <typename F,
FMT_ENABLE_IF(sizeof(F::_p) != 0 && !FMT_USE_FALLBACK_FILE)>
static auto get_file(F* f, int) -> apple_file<F> {
return f;
}