From 8f4ea166a2085dfb6054fb4de0f5dd373dd9f08d Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Mon, 30 Sep 2019 10:05:01 -0400 Subject: [PATCH] Fix old-style-cast warnings Fixes "error: use of old-style cast [-Werror=old-style-cast]" when compiling with GCC 7.4. --- include/ghc/filesystem.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/include/ghc/filesystem.hpp b/include/ghc/filesystem.hpp index c18745c..337bfcd 100644 --- a/include/ghc/filesystem.hpp +++ b/include/ghc/filesystem.hpp @@ -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(c - lo) < (hi - lo + 1)); } GHC_INLINE bool is_surrogate(uint32_t c) @@ -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(*iter++), codepoint)) == S_RJCT) { return false; } } @@ -1310,14 +1310,14 @@ 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(*iter++), codepoint)) == S_STRT) { if (codepoint <= 0xffff) { - result += (typename StringType::value_type)codepoint; + result += static_cast(codepoint); } else { codepoint -= 0x10000; - result += (typename StringType::value_type)((codepoint >> 10) + 0xd800); - result += (typename StringType::value_type)((codepoint & 0x3ff) + 0xdc00); + result += static_cast((codepoint >> 10) + 0xd800); + result += static_cast((codepoint & 0x3ff) + 0xdc00); } codepoint = 0; } @@ -1325,7 +1325,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(0xfffd); utf8_state = S_STRT; codepoint = 0; #endif @@ -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(0xfffd); #endif } return result; @@ -1350,7 +1350,7 @@ 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(*iter++), codepoint)) == S_STRT) { result += static_cast(codepoint); codepoint = 0; } @@ -1358,7 +1358,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(0xfffd); utf8_state = S_STRT; codepoint = 0; #endif @@ -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(0xfffd); #endif } return result; @@ -1756,7 +1756,7 @@ GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec) #else size_t bufferSize = 256; while (true) { - std::vector buffer(bufferSize, (char)0); + std::vector buffer(bufferSize, static_cast(0)); auto rc = ::readlink(p.c_str(), buffer.data(), buffer.size()); if (rc < 0) { ec = detail::make_system_error();