diff --git a/.github/workflows/encodingcheck/encodingcheck.cpp b/.github/workflows/encodingcheck/encodingcheck.cpp index 7619f4af..ebddc146 100644 --- a/.github/workflows/encodingcheck/encodingcheck.cpp +++ b/.github/workflows/encodingcheck/encodingcheck.cpp @@ -25,7 +25,9 @@ constexpr void print(std::format_string fmt, Args&&... args) template constexpr void printerr(std::format_string fmt, Args&&... args) { + fflush(stderr); std::fputs(std::format(fmt, std::forward(args)...).c_str(), stderr); + fflush(stderr); } namespace fs = std::filesystem; @@ -41,6 +43,10 @@ bool checkutf8(fs::path file) close(fd); throw fs::filesystem_error("fstat()", std::error_code{errno, std::system_category()}); } + if (statbuf.st_size == 0) { + close(fd); + return true; + } auto ptr = static_cast(mmap(nullptr, statbuf.st_size, PROT_READ, MAP_PRIVATE, fd, 0)); if (ptr == MAP_FAILED) { throw fs::filesystem_error("mmap()", std::error_code{errno, std::system_category()}); @@ -92,6 +98,7 @@ int main() catch(const std::exception& err){ printerr("ERROR {} ({})\n", entry.path().c_str(), mime); printerr("{}", err.what()); + throw err; } }