Skip to content

Commit

Permalink
Merge pull request #32 from jwnimmer-tri/warning-old-style-cast
Browse files Browse the repository at this point in the history
Fix old-style-cast warnings
  • Loading branch information
gulrak authored Sep 30, 2019
2 parents 65b5409 + 8f4ea16 commit 9b9528c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions include/ghc/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ namespace detail {

GHC_INLINE bool in_range(uint32_t c, uint32_t lo, uint32_t hi)
{
return ((uint32_t)(c - lo) < (hi - lo + 1));
return (static_cast<uint32_t>(c - lo) < (hi - lo + 1));
}

GHC_INLINE bool is_surrogate(uint32_t c)
Expand Down Expand Up @@ -1279,7 +1279,7 @@ GHC_INLINE bool validUtf8(const std::string& utf8String)
unsigned utf8_state = S_STRT;
std::uint32_t codepoint = 0;
while (iter < utf8String.end()) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_RJCT) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast<uint8_t>(*iter++), codepoint)) == S_RJCT) {
return false;
}
}
Expand Down Expand Up @@ -1310,22 +1310,22 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
unsigned utf8_state = S_STRT;
std::uint32_t codepoint = 0;
while (iter < utf8String.end()) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_STRT) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast<uint8_t>(*iter++), codepoint)) == S_STRT) {
if (codepoint <= 0xffff) {
result += (typename StringType::value_type)codepoint;
result += static_cast<typename StringType::value_type>(codepoint);
}
else {
codepoint -= 0x10000;
result += (typename StringType::value_type)((codepoint >> 10) + 0xd800);
result += (typename StringType::value_type)((codepoint & 0x3ff) + 0xdc00);
result += static_cast<typename StringType::value_type>((codepoint >> 10) + 0xd800);
result += static_cast<typename StringType::value_type>((codepoint & 0x3ff) + 0xdc00);
}
codepoint = 0;
}
else if (utf8_state == S_RJCT) {
#ifdef GHC_RAISE_UNICODE_ERRORS
throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence));
#else
result += (typename StringType::value_type)0xfffd;
result += static_cast<typename StringType::value_type>(0xfffd);
utf8_state = S_STRT;
codepoint = 0;
#endif
Expand All @@ -1335,7 +1335,7 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
#ifdef GHC_RAISE_UNICODE_ERRORS
throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence));
#else
result += (typename StringType::value_type)0xfffd;
result += static_cast<typename StringType::value_type>(0xfffd);
#endif
}
return result;
Expand All @@ -1350,15 +1350,15 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
unsigned utf8_state = S_STRT;
std::uint32_t codepoint = 0;
while (iter < utf8String.end()) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_STRT) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast<uint8_t>(*iter++), codepoint)) == S_STRT) {
result += static_cast<typename StringType::value_type>(codepoint);
codepoint = 0;
}
else if (utf8_state == S_RJCT) {
#ifdef GHC_RAISE_UNICODE_ERRORS
throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence));
#else
result += (typename StringType::value_type)0xfffd;
result += static_cast<typename StringType::value_type>(0xfffd);
utf8_state = S_STRT;
codepoint = 0;
#endif
Expand All @@ -1368,7 +1368,7 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
#ifdef GHC_RAISE_UNICODE_ERRORS
throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence));
#else
result += (typename StringType::value_type)0xfffd;
result += static_cast<typename StringType::value_type>(0xfffd);
#endif
}
return result;
Expand Down Expand Up @@ -1756,7 +1756,7 @@ GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec)
#else
size_t bufferSize = 256;
while (true) {
std::vector<char> buffer(bufferSize, (char)0);
std::vector<char> buffer(bufferSize, static_cast<char>(0));
auto rc = ::readlink(p.c_str(), buffer.data(), buffer.size());
if (rc < 0) {
ec = detail::make_system_error();
Expand Down

0 comments on commit 9b9528c

Please sign in to comment.