1
0
mirror of https://github.com/anope/anope.git synced 2026-06-12 17:24:49 +02:00

Update the vendored libraries.

This commit is contained in:
Sadie Powell
2025-10-05 17:36:34 +01:00
parent 7a09cebcfb
commit 0b3e55ed8f
3 changed files with 45 additions and 36 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ This directory contains vendored dependencies that are shipped with Anope to avo
**License** — Boost Software License **License** — Boost Software License
**Version** — v4.0.6 **Version** — v4.0.8
**Website** — [https://github.com/nemtrif/utfcpp](https://github.com/nemtrif/utfcpp) **Website** — [https://github.com/nemtrif/utfcpp](https://github.com/nemtrif/utfcpp)
+33 -23
View File
@@ -43,9 +43,14 @@ DEALINGS IN THE SOFTWARE.
#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later #if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
#define UTF_CPP_OVERRIDE override #define UTF_CPP_OVERRIDE override
#define UTF_CPP_NOEXCEPT noexcept #define UTF_CPP_NOEXCEPT noexcept
#define UTF_CPP_STATIC_ASSERT(condition) static_assert(condition, "UTFCPP static assert");
#else // C++ 98/03 #else // C++ 98/03
#define UTF_CPP_OVERRIDE #define UTF_CPP_OVERRIDE
#define UTF_CPP_NOEXCEPT throw() #define UTF_CPP_NOEXCEPT throw()
// Simulate static_assert:
template <bool Condition> struct StaticAssert {static void utf8_static_assert() {char static_assert_impl[Condition ? 1 : 0]; } };
template <> struct StaticAssert<true> {static void utf8_static_assert() {}};
#define UTF_CPP_STATIC_ASSERT(condition) StaticAssert<condition>::utf8_static_assert();
#endif // C++ 11 or later #endif // C++ 11 or later
@@ -87,6 +92,7 @@ namespace internal
{ {
return static_cast<utfchar8_t>(0xff & oc); return static_cast<utfchar8_t>(0xff & oc);
} }
template<typename u16_type> template<typename u16_type>
inline utfchar16_t mask16(u16_type oc) inline utfchar16_t mask16(u16_type oc)
{ {
@@ -101,17 +107,17 @@ namespace internal
inline bool is_lead_surrogate(utfchar32_t cp) inline bool is_lead_surrogate(utfchar32_t cp)
{ {
return (cp >= LEAD_SURROGATE_MIN && cp <= LEAD_SURROGATE_MAX); return (cp >= static_cast<utfchar32_t>(LEAD_SURROGATE_MIN) && cp <= static_cast<utfchar32_t>(LEAD_SURROGATE_MAX));
} }
inline bool is_trail_surrogate(utfchar32_t cp) inline bool is_trail_surrogate(utfchar32_t cp)
{ {
return (cp >= TRAIL_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX); return (cp >= static_cast<utfchar32_t>(TRAIL_SURROGATE_MIN) && cp <= static_cast<utfchar32_t>(TRAIL_SURROGATE_MAX));
} }
inline bool is_surrogate(utfchar32_t cp) inline bool is_surrogate(utfchar32_t cp)
{ {
return (cp >= LEAD_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX); return (cp >= static_cast<utfchar32_t>(LEAD_SURROGATE_MIN) && cp <= static_cast<utfchar32_t>(TRAIL_SURROGATE_MAX));
} }
inline bool is_code_point_valid(utfchar32_t cp) inline bool is_code_point_valid(utfchar32_t cp)
@@ -143,15 +149,15 @@ namespace internal
inline bool is_overlong_sequence(utfchar32_t cp, int length) inline bool is_overlong_sequence(utfchar32_t cp, int length)
{ {
if (cp < 0x80) { if (cp < 0x80) {
if (length != 1) if (length != 1)
return true; return true;
} }
else if (cp < 0x800) { else if (cp < 0x800) {
if (length != 2) if (length != 2)
return true; return true;
} }
else if (cp < 0x10000) { else if (cp < 0x10000) {
if (length != 3) if (length != 3)
return true; return true;
} }
return false; return false;
@@ -181,7 +187,7 @@ namespace internal
if (it == end) if (it == end)
return NOT_ENOUGH_ROOM; return NOT_ENOUGH_ROOM;
code_point = utf8::internal::mask8(*it); code_point = static_cast<utfchar32_t>(utf8::internal::mask8(*it));
return UTF8_OK; return UTF8_OK;
} }
@@ -189,10 +195,10 @@ namespace internal
template <typename octet_iterator> template <typename octet_iterator>
utf_error get_sequence_2(octet_iterator& it, octet_iterator end, utfchar32_t& code_point) utf_error get_sequence_2(octet_iterator& it, octet_iterator end, utfchar32_t& code_point)
{ {
if (it == end) if (it == end)
return NOT_ENOUGH_ROOM; return NOT_ENOUGH_ROOM;
code_point = utf8::internal::mask8(*it); code_point = static_cast<utfchar32_t>(utf8::internal::mask8(*it));
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
@@ -206,8 +212,8 @@ namespace internal
{ {
if (it == end) if (it == end)
return NOT_ENOUGH_ROOM; return NOT_ENOUGH_ROOM;
code_point = utf8::internal::mask8(*it); code_point = static_cast<utfchar32_t>(utf8::internal::mask8(*it));
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
@@ -226,7 +232,7 @@ namespace internal
if (it == end) if (it == end)
return NOT_ENOUGH_ROOM; return NOT_ENOUGH_ROOM;
code_point = utf8::internal::mask8(*it); code_point = static_cast<utfchar32_t>(utf8::internal::mask8(*it));
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end) UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
@@ -290,7 +296,7 @@ namespace internal
else else
err = OVERLONG_SEQUENCE; err = OVERLONG_SEQUENCE;
} }
else else
err = INVALID_CODE_POINT; err = INVALID_CODE_POINT;
} }
@@ -308,6 +314,10 @@ namespace internal
template <typename word_iterator> template <typename word_iterator>
utf_error validate_next16(word_iterator& it, word_iterator end, utfchar32_t& code_point) utf_error validate_next16(word_iterator& it, word_iterator end, utfchar32_t& code_point)
{ {
// Make sure the iterator dereferences a large enough type
typedef typename std::iterator_traits<word_iterator>::value_type word_type;
UTF_CPP_STATIC_ASSERT(sizeof(word_type) >= sizeof(utfchar16_t));
// Check the edge case:
if (it == end) if (it == end)
return NOT_ENOUGH_ROOM; return NOT_ENOUGH_ROOM;
// Save the original value of it so we can go back in case of failure // Save the original value of it so we can go back in case of failure
@@ -326,14 +336,14 @@ namespace internal
err = NOT_ENOUGH_ROOM; err = NOT_ENOUGH_ROOM;
else if (is_lead_surrogate(first_word)) { else if (is_lead_surrogate(first_word)) {
const utfchar16_t second_word = *it++; const utfchar16_t second_word = *it++;
if (is_trail_surrogate(second_word)) { if (is_trail_surrogate(static_cast<utfchar32_t>(second_word))) {
code_point = static_cast<utfchar32_t>(first_word << 10) + second_word + SURROGATE_OFFSET; code_point = static_cast<utfchar32_t>(first_word << 10) + static_cast<utfchar32_t>(second_word) + SURROGATE_OFFSET;
return UTF8_OK; return UTF8_OK;
} else } else
err = INCOMPLETE_SEQUENCE; err = INCOMPLETE_SEQUENCE;
} else { } else {
err = INVALID_LEAD; err = INVALID_LEAD;
} }
} }
// error branch // error branch
@@ -365,7 +375,7 @@ namespace internal
} }
return result; return result;
} }
// One of the following overloads will be invoked from the API calls // One of the following overloads will be invoked from the API calls
// A simple (but dangerous) case: the caller appends byte(s) to a char array // A simple (but dangerous) case: the caller appends byte(s) to a char array
@@ -395,6 +405,7 @@ namespace internal
// the word_type. // the word_type.
template <typename word_iterator, typename word_type> template <typename word_iterator, typename word_type>
word_iterator append16(utfchar32_t cp, word_iterator result) { word_iterator append16(utfchar32_t cp, word_iterator result) {
UTF_CPP_STATIC_ASSERT(sizeof(word_type) >= sizeof(utfchar16_t));
if (is_in_bmp(cp)) if (is_in_bmp(cp))
*(result++) = static_cast<word_type>(cp); *(result++) = static_cast<word_type>(cp);
else { else {
@@ -444,7 +455,7 @@ namespace internal
inline const char* find_invalid(const char* str) inline const char* find_invalid(const char* str)
{ {
const char* end = str + std::strlen(str); const char* end = str + std::strlen(str);
return find_invalid(str, end); return find_invalid(str, end);
} }
inline std::size_t find_invalid(const std::string& s) inline std::size_t find_invalid(const std::string& s)
@@ -484,9 +495,8 @@ namespace internal
inline bool starts_with_bom(const std::string& s) inline bool starts_with_bom(const std::string& s)
{ {
return starts_with_bom(s.begin(), s.end()); return starts_with_bom(s.begin(), s.end());
} }
} // namespace utf8 } // namespace utf8
#endif // header guard #endif // header guard
+11 -12
View File
@@ -82,7 +82,7 @@ namespace utf8
template <typename octet_iterator, typename output_iterator> template <typename octet_iterator, typename output_iterator>
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out) inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
{ {
static const utfchar32_t replacement_marker = utf8::internal::mask16(0xfffd); static const utfchar32_t replacement_marker = static_cast<utfchar32_t>(utf8::internal::mask16(0xfffd));
return utf8::unchecked::replace_invalid(start, end, out, replacement_marker); return utf8::unchecked::replace_invalid(start, end, out, replacement_marker);
} }
@@ -108,22 +108,22 @@ namespace utf8
case 1: case 1:
break; break;
case 2: case 2:
it++; ++it;
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f); cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
break; break;
case 3: case 3:
++it; ++it;
cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff); cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
++it; ++it;
cp = static_cast<utfchar32_t>(cp + ((*it) & 0x3f)); cp = static_cast<utfchar32_t>(cp + ((*it) & 0x3f));
break; break;
case 4: case 4:
++it; ++it;
cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff); cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
++it; ++it;
cp = static_cast<utfchar32_t>(cp + ((utf8::internal::mask8(*it) << 6) & 0xfff)); cp = static_cast<utfchar32_t>(cp + ((utf8::internal::mask8(*it) << 6) & 0xfff));
++it; ++it;
cp = static_cast<utfchar32_t>(cp + ((*it) & 0x3f)); cp = static_cast<utfchar32_t>(cp + ((*it) & 0x3f));
break; break;
} }
++it; ++it;
@@ -173,7 +173,7 @@ namespace utf8
distance(octet_iterator first, octet_iterator last) distance(octet_iterator first, octet_iterator last)
{ {
typename std::iterator_traits<octet_iterator>::difference_type dist; typename std::iterator_traits<octet_iterator>::difference_type dist;
for (dist = 0; first < last; ++dist) for (dist = 0; first < last; ++dist)
utf8::unchecked::next(first); utf8::unchecked::next(first);
return dist; return dist;
} }
@@ -247,15 +247,15 @@ namespace utf8
octet_iterator temp = it; octet_iterator temp = it;
return utf8::unchecked::next(temp); return utf8::unchecked::next(temp);
} }
bool operator == (const iterator& rhs) const bool operator == (const iterator& rhs) const
{ {
return (it == rhs.it); return (it == rhs.it);
} }
bool operator != (const iterator& rhs) const bool operator != (const iterator& rhs) const
{ {
return !(operator == (rhs)); return !(operator == (rhs));
} }
iterator& operator ++ () iterator& operator ++ ()
{ {
::std::advance(it, utf8::internal::sequence_length(it)); ::std::advance(it, utf8::internal::sequence_length(it));
return *this; return *this;
@@ -265,7 +265,7 @@ namespace utf8
iterator temp = *this; iterator temp = *this;
::std::advance(it, utf8::internal::sequence_length(it)); ::std::advance(it, utf8::internal::sequence_length(it));
return temp; return temp;
} }
iterator& operator -- () iterator& operator -- ()
{ {
utf8::unchecked::prior(it); utf8::unchecked::prior(it);
@@ -280,8 +280,7 @@ namespace utf8
}; // class iterator }; // class iterator
} // namespace utf8::unchecked } // namespace utf8::unchecked
} // namespace utf8 } // namespace utf8
#endif // header guard #endif // header guard