mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Simplify fallback
This commit is contained in:
17
test/scan.h
17
test/scan.h
@ -244,6 +244,15 @@ class file_scan_buffer : public scan_buffer {
|
|||||||
private:
|
private:
|
||||||
decltype(get_file(static_cast<FILE*>(nullptr), 0)) file_;
|
decltype(get_file(static_cast<FILE*>(nullptr), 0)) file_;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static void flockfile(FILE* f) {
|
||||||
|
_lock_file(f);
|
||||||
|
}
|
||||||
|
static void funlockfile(FILE* f) {
|
||||||
|
_unlock_file(file_);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void fill() {
|
void fill() {
|
||||||
string_view buf = file_.buffer();
|
string_view buf = file_.buffer();
|
||||||
if (buf.size() == 0) {
|
if (buf.size() == 0) {
|
||||||
@ -266,19 +275,11 @@ class file_scan_buffer : public scan_buffer {
|
|||||||
public:
|
public:
|
||||||
explicit file_scan_buffer(FILE* f)
|
explicit file_scan_buffer(FILE* f)
|
||||||
: scan_buffer(nullptr, nullptr, false), file_(f) {
|
: scan_buffer(nullptr, nullptr, false), file_(f) {
|
||||||
#ifndef _WIN32
|
|
||||||
flockfile(f);
|
flockfile(f);
|
||||||
#else
|
|
||||||
_lock_file(f);
|
|
||||||
#endif
|
|
||||||
fill();
|
fill();
|
||||||
}
|
}
|
||||||
~file_scan_buffer() {
|
~file_scan_buffer() {
|
||||||
#ifndef _WIN32
|
|
||||||
funlockfile(file_);
|
funlockfile(file_);
|
||||||
#else
|
|
||||||
_unlock_file(file_);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
Reference in New Issue
Block a user