Commit 2dad1690 authored by Victor Zverovich's avatar Victor Zverovich

Fix BufferefFile test on Windows.

parent 564da259
......@@ -71,13 +71,9 @@ fmt::BufferedFile::~BufferedFile() FMT_NOEXCEPT(true) {
}
fmt::BufferedFile::BufferedFile(fmt::StringRef filename, fmt::StringRef mode) {
for (;;) {
file_ = FMT_SYSTEM(fopen(filename.c_str(), mode.c_str()));
if (file_)
return;
if (errno != EINTR)
throw SystemError(errno, "cannot open file");
}
FMT_RETRY_VAL(file_, FMT_SYSTEM(fopen(filename.c_str(), mode.c_str())), 0);
if (!file_)
throw SystemError(errno, "cannot open file");
}
void fmt::BufferedFile::close() {
......
......@@ -63,16 +63,19 @@
# endif
#endif
// Retries the expression while it evaluates to -1 and error equals to EINTR.
// Retries the expression while it evaluates to error_result and errno
// equals to EINTR.
#ifndef _WIN32
# define FMT_RETRY(result, expression) \
# define FMT_RETRY_VAL(result, expression, error_result) \
do { \
result = (expression); \
} while (result == -1 && errno == EINTR)
} while (result == error_result && errno == EINTR)
#else
# define FMT_RETRY(result, expression) result = (expression)
#endif
#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
namespace fmt {
// An error code.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment