mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-01 02:41:48 +00:00
[wpiutil] Modify fmt to not throw on write failure (#3919)
This was causing issues with tools, as the launchers would close stdout/stderr, resulting in write failures.
This commit is contained in:
42
upstream_utils/fmt-dont-throw-on-write-failure.patch
Normal file
42
upstream_utils/fmt-dont-throw-on-write-failure.patch
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
diff --git a/wpiutil/src/main/native/fmtlib/include/fmt/format-inl.h b/wpiutil/src/main/native/fmtlib/include/fmt/format-inl.h
|
||||||
|
index 2c51c50ae..cc89abdd3 100644
|
||||||
|
--- a/wpiutil/src/main/native/fmtlib/include/fmt/format-inl.h
|
||||||
|
+++ b/wpiutil/src/main/native/fmtlib/include/fmt/format-inl.h
|
||||||
|
@@ -92,8 +92,7 @@ FMT_FUNC void report_error(format_func func, int error_code,
|
||||||
|
// A wrapper around fwrite that throws on error.
|
||||||
|
inline void fwrite_fully(const void* ptr, size_t size, size_t count,
|
||||||
|
FILE* stream) {
|
||||||
|
- size_t written = std::fwrite(ptr, size, count, stream);
|
||||||
|
- if (written < count) FMT_THROW(system_error(errno, "cannot write to file"));
|
||||||
|
+ std::fwrite(ptr, size, count, stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
||||||
|
diff --git a/wpiutil/src/main/native/fmtlib/include/fmt/xchar.h b/wpiutil/src/main/native/fmtlib/include/fmt/xchar.h
|
||||||
|
index 55825077f..9acb893fa 100644
|
||||||
|
--- a/wpiutil/src/main/native/fmtlib/include/fmt/xchar.h
|
||||||
|
+++ b/wpiutil/src/main/native/fmtlib/include/fmt/xchar.h
|
||||||
|
@@ -207,8 +207,7 @@ inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
|
||||||
|
wmemory_buffer buffer;
|
||||||
|
detail::vformat_to(buffer, fmt, args);
|
||||||
|
buffer.push_back(L'\0');
|
||||||
|
- if (std::fputws(buffer.data(), f) == -1)
|
||||||
|
- FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
||||||
|
+ std::fputws(buffer.data(), f);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void vprint(wstring_view fmt, wformat_args args) {
|
||||||
|
diff --git a/wpiutil/src/main/native/fmtlib/src/os.cpp b/wpiutil/src/main/native/fmtlib/src/os.cpp
|
||||||
|
index 04b4dc506..4eb3e1fdd 100644
|
||||||
|
--- a/wpiutil/src/main/native/fmtlib/src/os.cpp
|
||||||
|
+++ b/wpiutil/src/main/native/fmtlib/src/os.cpp
|
||||||
|
@@ -277,8 +277,7 @@ std::size_t file::read(void* buffer, std::size_t count) {
|
||||||
|
std::size_t file::write(const void* buffer, std::size_t count) {
|
||||||
|
rwresult result = 0;
|
||||||
|
FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count))));
|
||||||
|
- if (result < 0) FMT_THROW(system_error(errno, "cannot write to file"));
|
||||||
|
- return detail::to_unsigned(result);
|
||||||
|
+ return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
file file::dup(int fd) {
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if
|
from upstream_utils import setup_upstream_repo, comment_out_invalid_includes, walk_cwd_and_copy_if, apply_patches
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -31,6 +31,9 @@ def main():
|
|||||||
comment_out_invalid_includes(
|
comment_out_invalid_includes(
|
||||||
f, [os.path.join(wpiutil, "src/main/native/fmtlib/include")])
|
f, [os.path.join(wpiutil, "src/main/native/fmtlib/include")])
|
||||||
|
|
||||||
|
apply_patches(root,
|
||||||
|
["upstream_utils/fmt-dont-throw-on-write-failure.patch"])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -92,8 +92,7 @@ FMT_FUNC void report_error(format_func func, int error_code,
|
|||||||
// A wrapper around fwrite that throws on error.
|
// A wrapper around fwrite that throws on error.
|
||||||
inline void fwrite_fully(const void* ptr, size_t size, size_t count,
|
inline void fwrite_fully(const void* ptr, size_t size, size_t count,
|
||||||
FILE* stream) {
|
FILE* stream) {
|
||||||
size_t written = std::fwrite(ptr, size, count, stream);
|
std::fwrite(ptr, size, count, stream);
|
||||||
if (written < count) FMT_THROW(system_error(errno, "cannot write to file"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
||||||
|
|||||||
@@ -207,8 +207,7 @@ inline void vprint(std::FILE* f, wstring_view fmt, wformat_args args) {
|
|||||||
wmemory_buffer buffer;
|
wmemory_buffer buffer;
|
||||||
detail::vformat_to(buffer, fmt, args);
|
detail::vformat_to(buffer, fmt, args);
|
||||||
buffer.push_back(L'\0');
|
buffer.push_back(L'\0');
|
||||||
if (std::fputws(buffer.data(), f) == -1)
|
std::fputws(buffer.data(), f);
|
||||||
FMT_THROW(system_error(errno, FMT_STRING("cannot write to file")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void vprint(wstring_view fmt, wformat_args args) {
|
inline void vprint(wstring_view fmt, wformat_args args) {
|
||||||
|
|||||||
@@ -277,8 +277,7 @@ std::size_t file::read(void* buffer, std::size_t count) {
|
|||||||
std::size_t file::write(const void* buffer, std::size_t count) {
|
std::size_t file::write(const void* buffer, std::size_t count) {
|
||||||
rwresult result = 0;
|
rwresult result = 0;
|
||||||
FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count))));
|
FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count))));
|
||||||
if (result < 0) FMT_THROW(system_error(errno, "cannot write to file"));
|
return count;
|
||||||
return detail::to_unsigned(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file file::dup(int fd) {
|
file file::dup(int fd) {
|
||||||
|
|||||||
Reference in New Issue
Block a user