mirror of
https://github.com/anope/anope.git
synced 2026-06-12 15:44:46 +02:00
Update the vendored libraries.
This commit is contained in:
Vendored
+1
-1
@@ -38,7 +38,7 @@ This directory contains vendored dependencies that are shipped with Anope to avo
|
||||
|
||||
**License** — Boost Software License
|
||||
|
||||
**Version** — v4.0.6
|
||||
**Version** — v4.0.8
|
||||
|
||||
**Website** — [https://github.com/nemtrif/utfcpp](https://github.com/nemtrif/utfcpp)
|
||||
|
||||
|
||||
Vendored
+33
-23
@@ -43,9 +43,14 @@ DEALINGS IN THE SOFTWARE.
|
||||
#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
|
||||
#define UTF_CPP_OVERRIDE override
|
||||
#define UTF_CPP_NOEXCEPT noexcept
|
||||
#define UTF_CPP_STATIC_ASSERT(condition) static_assert(condition, "UTFCPP static assert");
|
||||
#else // C++ 98/03
|
||||
#define UTF_CPP_OVERRIDE
|
||||
#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
|
||||
|
||||
|
||||
@@ -87,6 +92,7 @@ namespace internal
|
||||
{
|
||||
return static_cast<utfchar8_t>(0xff & oc);
|
||||
}
|
||||
|
||||
template<typename u16_type>
|
||||
inline utfchar16_t mask16(u16_type oc)
|
||||
{
|
||||
@@ -101,17 +107,17 @@ namespace internal
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
@@ -143,15 +149,15 @@ namespace internal
|
||||
inline bool is_overlong_sequence(utfchar32_t cp, int length)
|
||||
{
|
||||
if (cp < 0x80) {
|
||||
if (length != 1)
|
||||
if (length != 1)
|
||||
return true;
|
||||
}
|
||||
else if (cp < 0x800) {
|
||||
if (length != 2)
|
||||
if (length != 2)
|
||||
return true;
|
||||
}
|
||||
else if (cp < 0x10000) {
|
||||
if (length != 3)
|
||||
if (length != 3)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -181,7 +187,7 @@ namespace internal
|
||||
if (it == end)
|
||||
return NOT_ENOUGH_ROOM;
|
||||
|
||||
code_point = utf8::internal::mask8(*it);
|
||||
code_point = static_cast<utfchar32_t>(utf8::internal::mask8(*it));
|
||||
|
||||
return UTF8_OK;
|
||||
}
|
||||
@@ -189,10 +195,10 @@ namespace internal
|
||||
template <typename octet_iterator>
|
||||
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;
|
||||
|
||||
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)
|
||||
|
||||
@@ -206,8 +212,8 @@ namespace internal
|
||||
{
|
||||
if (it == end)
|
||||
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)
|
||||
|
||||
@@ -226,7 +232,7 @@ namespace internal
|
||||
if (it == end)
|
||||
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)
|
||||
|
||||
@@ -290,7 +296,7 @@ namespace internal
|
||||
else
|
||||
err = OVERLONG_SEQUENCE;
|
||||
}
|
||||
else
|
||||
else
|
||||
err = INVALID_CODE_POINT;
|
||||
}
|
||||
|
||||
@@ -308,6 +314,10 @@ namespace internal
|
||||
template <typename word_iterator>
|
||||
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)
|
||||
return NOT_ENOUGH_ROOM;
|
||||
// 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;
|
||||
else if (is_lead_surrogate(first_word)) {
|
||||
const utfchar16_t second_word = *it++;
|
||||
if (is_trail_surrogate(second_word)) {
|
||||
code_point = static_cast<utfchar32_t>(first_word << 10) + second_word + SURROGATE_OFFSET;
|
||||
if (is_trail_surrogate(static_cast<utfchar32_t>(second_word))) {
|
||||
code_point = static_cast<utfchar32_t>(first_word << 10) + static_cast<utfchar32_t>(second_word) + SURROGATE_OFFSET;
|
||||
return UTF8_OK;
|
||||
} else
|
||||
err = INCOMPLETE_SEQUENCE;
|
||||
|
||||
} else
|
||||
err = INCOMPLETE_SEQUENCE;
|
||||
|
||||
} else {
|
||||
err = INVALID_LEAD;
|
||||
err = INVALID_LEAD;
|
||||
}
|
||||
}
|
||||
// error branch
|
||||
@@ -365,7 +375,7 @@ namespace internal
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
@@ -395,6 +405,7 @@ namespace internal
|
||||
// the word_type.
|
||||
template <typename word_iterator, typename word_type>
|
||||
word_iterator append16(utfchar32_t cp, word_iterator result) {
|
||||
UTF_CPP_STATIC_ASSERT(sizeof(word_type) >= sizeof(utfchar16_t));
|
||||
if (is_in_bmp(cp))
|
||||
*(result++) = static_cast<word_type>(cp);
|
||||
else {
|
||||
@@ -444,7 +455,7 @@ namespace internal
|
||||
inline const char* find_invalid(const char* 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)
|
||||
@@ -484,9 +495,8 @@ namespace internal
|
||||
inline bool starts_with_bom(const std::string& s)
|
||||
{
|
||||
return starts_with_bom(s.begin(), s.end());
|
||||
}
|
||||
}
|
||||
} // namespace utf8
|
||||
|
||||
#endif // header guard
|
||||
|
||||
|
||||
|
||||
Vendored
+11
-12
@@ -82,7 +82,7 @@ namespace utf8
|
||||
template <typename octet_iterator, typename output_iterator>
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -108,22 +108,22 @@ namespace utf8
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
it++;
|
||||
++it;
|
||||
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
|
||||
break;
|
||||
case 3:
|
||||
++it;
|
||||
++it;
|
||||
cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
|
||||
++it;
|
||||
cp = static_cast<utfchar32_t>(cp + ((*it) & 0x3f));
|
||||
break;
|
||||
case 4:
|
||||
++it;
|
||||
cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
|
||||
cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
|
||||
++it;
|
||||
cp = static_cast<utfchar32_t>(cp + ((utf8::internal::mask8(*it) << 6) & 0xfff));
|
||||
++it;
|
||||
cp = static_cast<utfchar32_t>(cp + ((*it) & 0x3f));
|
||||
cp = static_cast<utfchar32_t>(cp + ((*it) & 0x3f));
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
@@ -173,7 +173,7 @@ namespace utf8
|
||||
distance(octet_iterator first, octet_iterator last)
|
||||
{
|
||||
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);
|
||||
return dist;
|
||||
}
|
||||
@@ -247,15 +247,15 @@ namespace utf8
|
||||
octet_iterator temp = it;
|
||||
return utf8::unchecked::next(temp);
|
||||
}
|
||||
bool operator == (const iterator& rhs) const
|
||||
{
|
||||
bool operator == (const iterator& rhs) const
|
||||
{
|
||||
return (it == rhs.it);
|
||||
}
|
||||
bool operator != (const iterator& rhs) const
|
||||
{
|
||||
return !(operator == (rhs));
|
||||
}
|
||||
iterator& operator ++ ()
|
||||
iterator& operator ++ ()
|
||||
{
|
||||
::std::advance(it, utf8::internal::sequence_length(it));
|
||||
return *this;
|
||||
@@ -265,7 +265,7 @@ namespace utf8
|
||||
iterator temp = *this;
|
||||
::std::advance(it, utf8::internal::sequence_length(it));
|
||||
return temp;
|
||||
}
|
||||
}
|
||||
iterator& operator -- ()
|
||||
{
|
||||
utf8::unchecked::prior(it);
|
||||
@@ -280,8 +280,7 @@ namespace utf8
|
||||
}; // class iterator
|
||||
|
||||
} // namespace utf8::unchecked
|
||||
} // namespace utf8
|
||||
|
||||
} // namespace utf8
|
||||
|
||||
#endif // header guard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user