From 0a9d08fefd23e861b7675dc4808fad885a9a45a4 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 25 Dec 2023 09:00:03 -0800 Subject: [PATCH] Simplify fallback --- test/scan.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/scan.h b/test/scan.h index ea7c51ba..c5dcb772 100644 --- a/test/scan.h +++ b/test/scan.h @@ -244,6 +244,15 @@ class file_scan_buffer : public scan_buffer { private: decltype(get_file(static_cast(nullptr), 0)) file_; +#ifdef _WIN32 + static void flockfile(FILE* f) { + _lock_file(f); + } + static void funlockfile(FILE* f) { + _unlock_file(file_); + } +#endif + void fill() { string_view buf = file_.buffer(); if (buf.size() == 0) { @@ -266,19 +275,11 @@ class file_scan_buffer : public scan_buffer { public: explicit file_scan_buffer(FILE* f) : scan_buffer(nullptr, nullptr, false), file_(f) { -#ifndef _WIN32 flockfile(f); -#else - _lock_file(f); -#endif fill(); } ~file_scan_buffer() { -#ifndef _WIN32 funlockfile(file_); -#else - _unlock_file(file_); -#endif } }; } // namespace detail