From 458aeee83c41e099b8e5e2ef40afcaa5542cd724 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 8 Jun 2023 19:51:32 +0200 Subject: [PATCH] Use the C++11 cstdint header instead of the boost fallback --- include/boost/locale/boundary/index.hpp | 2 +- include/boost/locale/boundary/types.hpp | 2 +- include/boost/locale/date_time_facet.hpp | 2 +- include/boost/locale/formatting.hpp | 2 +- include/boost/locale/generator.hpp | 2 +- include/boost/locale/generic_codecvt.hpp | 28 ++++++++++++------------ include/boost/locale/utf.hpp | 2 +- include/boost/locale/utf8_codecvt.hpp | 2 +- include/boost/locale/util.hpp | 2 +- src/boost/locale/icu/formatter.hpp | 2 +- src/boost/locale/icu/icu_util.hpp | 4 +--- src/boost/locale/icu/time_zone.hpp | 4 +--- src/boost/locale/shared/mo_hash.hpp | 2 +- test/test_utf.cpp | 16 +++++++------- 14 files changed, 34 insertions(+), 38 deletions(-) diff --git a/include/boost/locale/boundary/index.hpp b/include/boost/locale/boundary/index.hpp index a953627..fb4319b 100644 --- a/include/boost/locale/boundary/index.hpp +++ b/include/boost/locale/boundary/index.hpp @@ -11,9 +11,9 @@ #include #include #include -#include #include #include +#include #include #include #include diff --git a/include/boost/locale/boundary/types.hpp b/include/boost/locale/boundary/types.hpp index 9fac23b..fa92791 100644 --- a/include/boost/locale/boundary/types.hpp +++ b/include/boost/locale/boundary/types.hpp @@ -8,7 +8,7 @@ #define BOOST_LOCALE_BOUNDARY_TYPES_HPP_INCLUDED #include -#include +#include #ifdef BOOST_MSVC # pragma warning(push) diff --git a/include/boost/locale/date_time_facet.hpp b/include/boost/locale/date_time_facet.hpp index 88e6c5d..2f3344b 100644 --- a/include/boost/locale/date_time_facet.hpp +++ b/include/boost/locale/date_time_facet.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #ifdef BOOST_MSVC diff --git a/include/boost/locale/formatting.hpp b/include/boost/locale/formatting.hpp index 9e77e6d..936ce7e 100644 --- a/include/boost/locale/formatting.hpp +++ b/include/boost/locale/formatting.hpp @@ -10,8 +10,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/include/boost/locale/generator.hpp b/include/boost/locale/generator.hpp index bfbd528..f2cac21 100644 --- a/include/boost/locale/generator.hpp +++ b/include/boost/locale/generator.hpp @@ -8,7 +8,7 @@ #define BOOST_LOCALE_GENERATOR_HPP #include -#include +#include #include #include #include diff --git a/include/boost/locale/generic_codecvt.hpp b/include/boost/locale/generic_codecvt.hpp index c05dc43..8a006d3 100644 --- a/include/boost/locale/generic_codecvt.hpp +++ b/include/boost/locale/generic_codecvt.hpp @@ -9,7 +9,7 @@ #define BOOST_LOCALE_GENERIC_CODECVT_HPP #include -#include +#include #include namespace boost { namespace locale { @@ -187,7 +187,7 @@ namespace boost { namespace locale { implementation().initial_state(generic_codecvt_base::to_unicode_state); while(max > 0 && from < from_end) { const char* prev_from = from; - boost::uint32_t ch = implementation().to_unicode(cvt_state, from, from_end); + std::uint32_t ch = implementation().to_unicode(cvt_state, from, from_end); if(ch == boost::locale::utf::incomplete || ch == boost::locale::utf::illegal) { from = prev_from; break; @@ -250,8 +250,8 @@ namespace boost { namespace locale { // once again and then we would consume our input together with writing // second surrogate pair ch -= 0x10000; - boost::uint16_t w1 = static_cast(0xD800 | (ch >> 10)); - boost::uint16_t w2 = static_cast(0xDC00 | (ch & 0x3FF)); + std::uint16_t w1 = static_cast(0xD800 | (ch >> 10)); + std::uint16_t w2 = static_cast(0xDC00 | (ch & 0x3FF)); if(!state) { from = from_saved; *to++ = w1; @@ -283,22 +283,22 @@ namespace boost { namespace locale { // // State: state!=0 - a first surrogate pair was observed (state = first pair), // we expect the second one to come and then zero the state - boost::uint16_t state = detail::read_state(std_state); + std::uint16_t state = detail::read_state(std_state); typename CodecvtImpl::state_type cvt_state = implementation().initial_state(generic_codecvt_base::from_unicode_state); while(to < to_end && from < from_end) { - boost::uint32_t ch = 0; + std::uint32_t ch = 0; if(state != 0) { // if the state indicates that 1st surrogate pair was written // we should make sure that the second one that comes is actually // second surrogate - boost::uint16_t w1 = state; - boost::uint16_t w2 = *from; + std::uint16_t w1 = state; + std::uint16_t w2 = *from; // we don't forward from as writing may fail to incomplete or // partial conversion if(0xDC00 <= w2 && w2 <= 0xDFFF) { - boost::uint16_t vh = w1 - 0xD800; - boost::uint16_t vl = w2 - 0xDC00; + std::uint16_t vh = w1 - 0xD800; + std::uint16_t vl = w2 - 0xDC00; ch = ((uint32_t(vh) << 10) | vl) + 0x10000; } else { // Invalid surrogate @@ -327,7 +327,7 @@ namespace boost { namespace locale { r = std::codecvt_base::error; break; } - boost::uint32_t len = implementation().from_unicode(cvt_state, ch, to, to_end); + std::uint32_t len = implementation().from_unicode(cvt_state, ch, to, to_end); if(len == boost::locale::utf::incomplete) { r = std::codecvt_base::partial; break; @@ -380,7 +380,7 @@ namespace boost { namespace locale { implementation().initial_state(generic_codecvt_base::to_unicode_state); while(max > 0 && from < from_end) { const char* save_from = from; - boost::uint32_t ch = implementation().to_unicode(cvt_state, from, from_end); + std::uint32_t ch = implementation().to_unicode(cvt_state, from, from_end); if(ch == boost::locale::utf::incomplete || ch == boost::locale::utf::illegal) { from = save_from; break; @@ -442,13 +442,13 @@ namespace boost { namespace locale { std::codecvt_base::result r = std::codecvt_base::ok; auto cvt_state = implementation().initial_state(generic_codecvt_base::from_unicode_state); while(to < to_end && from < from_end) { - boost::uint32_t ch = 0; + std::uint32_t ch = 0; ch = *from; if(!boost::locale::utf::is_valid_codepoint(ch)) { r = std::codecvt_base::error; break; } - boost::uint32_t len = implementation().from_unicode(cvt_state, ch, to, to_end); + std::uint32_t len = implementation().from_unicode(cvt_state, ch, to, to_end); if(len == boost::locale::utf::incomplete) { r = std::codecvt_base::partial; break; diff --git a/include/boost/locale/utf.hpp b/include/boost/locale/utf.hpp index a031cac..04d89e8 100644 --- a/include/boost/locale/utf.hpp +++ b/include/boost/locale/utf.hpp @@ -8,7 +8,7 @@ #define BOOST_LOCALE_UTF_HPP_INCLUDED #include -#include +#include namespace boost { namespace locale { /// \brief Namespace that holds basic operations on UTF encoded sequences diff --git a/include/boost/locale/utf8_codecvt.hpp b/include/boost/locale/utf8_codecvt.hpp index d2884c6..758fe4f 100644 --- a/include/boost/locale/utf8_codecvt.hpp +++ b/include/boost/locale/utf8_codecvt.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include namespace boost { namespace locale { diff --git a/include/boost/locale/util.hpp b/include/boost/locale/util.hpp index 2264c6c..ccfa912 100644 --- a/include/boost/locale/util.hpp +++ b/include/boost/locale/util.hpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/boost/locale/icu/formatter.hpp b/src/boost/locale/icu/formatter.hpp index 50461d4..110a031 100644 --- a/src/boost/locale/icu/formatter.hpp +++ b/src/boost/locale/icu/formatter.hpp @@ -8,7 +8,7 @@ #define BOOST_LOCALE_FORMATTER_HPP_INCLUDED #include -#include +#include #include #include #include diff --git a/src/boost/locale/icu/icu_util.hpp b/src/boost/locale/icu/icu_util.hpp index 871e3f8..70f4cef 100644 --- a/src/boost/locale/icu/icu_util.hpp +++ b/src/boost/locale/icu/icu_util.hpp @@ -9,9 +9,7 @@ #define BOOST_SRC_ICU_UTIL_HPP #include -#ifdef BOOST_HAS_STDINT_H -# include // Avoid ICU defining e.g. INT8_MIN causing macro redefinition warnings -#endif +#include // Avoid ICU defining e.g. INT8_MIN causing macro redefinition warnings #include #include #include diff --git a/src/boost/locale/icu/time_zone.hpp b/src/boost/locale/icu/time_zone.hpp index 132c5db..87ab0c4 100644 --- a/src/boost/locale/icu/time_zone.hpp +++ b/src/boost/locale/icu/time_zone.hpp @@ -8,9 +8,7 @@ #define BOOST_LOCALE_IMPL_ICU_GET_TIME_ZONE_HPP #include -#ifdef BOOST_HAS_STDINT_H -# include // Avoid ICU defining e.g. INT8_MIN causing macro redefinition warnings -#endif +#include // Avoid ICU defining e.g. INT8_MIN causing macro redefinition warnings #include #include diff --git a/src/boost/locale/shared/mo_hash.hpp b/src/boost/locale/shared/mo_hash.hpp index ad41764..702ea7a 100644 --- a/src/boost/locale/shared/mo_hash.hpp +++ b/src/boost/locale/shared/mo_hash.hpp @@ -4,7 +4,7 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt -#include +#include namespace boost { namespace locale { namespace gnu_gettext { diff --git a/test/test_utf.cpp b/test/test_utf.cpp index df0a8c3..f34206e 100644 --- a/test/test_utf.cpp +++ b/test/test_utf.cpp @@ -13,32 +13,32 @@ using namespace boost::locale::utf; -const boost::uint32_t* u32_seq(boost::uint32_t a) +const std::uint32_t* u32_seq(std::uint32_t a) { - static boost::uint32_t buf[2]; + static std::uint32_t buf[2]; buf[0] = a; buf[1] = 0; return buf; } -const boost::uint16_t* u16_seq(boost::uint16_t a) +const std::uint16_t* u16_seq(std::uint16_t a) { - static boost::uint16_t buf[2]; + static std::uint16_t buf[2]; buf[0] = a; buf[1] = 0; return buf; } -const boost::uint16_t* u16_seq(boost::uint16_t a, boost::uint16_t b) +const std::uint16_t* u16_seq(std::uint16_t a, std::uint16_t b) { - static boost::uint16_t buf[3]; + static std::uint16_t buf[3]; buf[0] = a; buf[1] = b; buf[2] = 0; return buf; } -const char16_t* c16_seq(boost::uint16_t a) +const char16_t* c16_seq(std::uint16_t a) { static char16_t buf[2]; buf[0] = static_cast(a); @@ -46,7 +46,7 @@ const char16_t* c16_seq(boost::uint16_t a) return buf; } -const char32_t* c32_seq(boost::uint32_t a) +const char32_t* c32_seq(std::uint32_t a) { static char32_t buf[2]; buf[0] = static_cast(a);