Skip to content

Commit 4968433

Browse files
committed
Minor cleanup
1 parent e824477 commit 4968433

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

src/os.cc

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161

6262
namespace {
6363
#ifdef _WIN32
64+
6465
// Return type of read and write functions.
6566
using rwresult = int;
6667

@@ -69,20 +70,6 @@ using rwresult = int;
6970
inline unsigned convert_rwcount(size_t count) {
7071
return count <= UINT_MAX ? static_cast<unsigned>(count) : UINT_MAX;
7172
}
72-
#elif FMT_USE_FCNTL
73-
// Return type of read and write functions.
74-
using rwresult = ssize_t;
75-
76-
inline auto convert_rwcount(size_t count) -> size_t { return count; }
77-
#endif
78-
} // namespace
79-
80-
FMT_BEGIN_NAMESPACE
81-
82-
#ifdef _WIN32
83-
namespace detail {
84-
85-
namespace {
8673

8774
class system_message {
8875
system_message(const system_message&) = delete;
@@ -111,8 +98,8 @@ class system_message {
11198
}
11299
~system_message() { LocalFree(message_); }
113100
explicit operator bool() const noexcept { return result_ != 0; }
114-
operator basic_string_view<wchar_t>() const noexcept {
115-
return basic_string_view<wchar_t>(message_, result_);
101+
operator fmt::basic_string_view<wchar_t>() const noexcept {
102+
return fmt::basic_string_view<wchar_t>(message_, result_);
116103
}
117104
};
118105

@@ -122,7 +109,7 @@ class utf8_system_category final : public std::error_category {
122109
std::string message(int error_code) const override {
123110
auto&& msg = system_message(error_code);
124111
if (msg) {
125-
auto utf8_message = to_utf8<wchar_t>();
112+
auto utf8_message = fmt::detail::to_utf8<wchar_t>();
126113
if (utf8_message.convert(msg)) {
127114
return utf8_message.str();
128115
}
@@ -131,12 +118,22 @@ class utf8_system_category final : public std::error_category {
131118
}
132119
};
133120

121+
#elif FMT_USE_FCNTL
122+
123+
// Return type of read and write functions.
124+
using rwresult = ssize_t;
125+
126+
inline auto convert_rwcount(size_t count) -> size_t { return count; }
127+
128+
#endif
134129
} // namespace
135130

136-
} // namespace detail
131+
FMT_BEGIN_NAMESPACE
132+
133+
#ifdef _WIN32
137134

138135
FMT_API const std::error_category& system_category() noexcept {
139-
static const detail::utf8_system_category category;
136+
static const utf8_system_category category;
140137
return category;
141138
}
142139

@@ -166,6 +163,7 @@ void detail::format_windows_error(detail::buffer<char>& out, int error_code,
166163
void report_windows_error(int error_code, const char* message) noexcept {
167164
do_report_error(detail::format_windows_error, error_code, message);
168165
}
166+
169167
#endif // _WIN32
170168

171169
buffered_file::~buffered_file() noexcept {

0 commit comments

Comments
 (0)