diff options
author | Remko Tronçon <git@el-tramo.be> | 2012-12-23 13:16:26 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-12-23 14:43:26 (GMT) |
commit | 491ddd570a752cf9bda85933bed0c6942e39b1f9 (patch) | |
tree | 10c25c1be8cc08d0497df1dccd56a10fbb30beee /3rdParty/Boost/src/boost/regex/pending | |
parent | da7d7a0ca71b80281aa9ff2526290b61ccb0cc60 (diff) | |
download | swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.zip swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.tar.bz2 |
Update Boost to 1.52.0.
Change-Id: I1e56bea2600bf2ed9c5b3aba8c4f9d2a0f350e77
Diffstat (limited to '3rdParty/Boost/src/boost/regex/pending')
-rw-r--r-- | 3rdParty/Boost/src/boost/regex/pending/object_cache.hpp | 4 | ||||
-rw-r--r-- | 3rdParty/Boost/src/boost/regex/pending/unicode_iterator.hpp | 78 |
2 files changed, 73 insertions, 9 deletions
diff --git a/3rdParty/Boost/src/boost/regex/pending/object_cache.hpp b/3rdParty/Boost/src/boost/regex/pending/object_cache.hpp index db60e28..d47fbba 100644 --- a/3rdParty/Boost/src/boost/regex/pending/object_cache.hpp +++ b/3rdParty/Boost/src/boost/regex/pending/object_cache.hpp @@ -73,7 +73,7 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::get(const Key& k, siz // for now just throw, but we should never really get here... // ::boost::throw_exception(std::runtime_error("Error in thread safety code: could not acquire a lock")); -#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION +#if defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION) || defined(BOOST_NO_EXCEPTIONS) return boost::shared_ptr<Object>(); #endif #else @@ -151,7 +151,7 @@ boost::shared_ptr<Object const> object_cache<Key, Object>::do_get(const Key& k, --s; } else - --pos; + ++pos; } BOOST_ASSERT(s_data.index[k]->first.get() == result.get()); BOOST_ASSERT(&(s_data.index.find(k)->first) == s_data.cont.back().second); diff --git a/3rdParty/Boost/src/boost/regex/pending/unicode_iterator.hpp b/3rdParty/Boost/src/boost/regex/pending/unicode_iterator.hpp index 657ca0a..e6399b5 100644 --- a/3rdParty/Boost/src/boost/regex/pending/unicode_iterator.hpp +++ b/3rdParty/Boost/src/boost/regex/pending/unicode_iterator.hpp @@ -82,16 +82,16 @@ static const ::boost::uint32_t ten_bit_mask = 0x3FFu; inline bool is_high_surrogate(::boost::uint16_t v) { - return (v & 0xFC00u) == 0xd800u; + return (v & 0xFFFFFC00u) == 0xd800u; } inline bool is_low_surrogate(::boost::uint16_t v) { - return (v & 0xFC00u) == 0xdc00u; + return (v & 0xFFFFFC00u) == 0xdc00u; } template <class T> inline bool is_surrogate(T v) { - return (v & 0xF800u) == 0xd800; + return (v & 0xFFFFF800u) == 0xd800; } inline unsigned utf8_byte_count(boost::uint8_t c) @@ -113,6 +113,10 @@ inline unsigned utf8_trailing_byte_count(boost::uint8_t c) return utf8_byte_count(c) - 1; } +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable:4100) +#endif inline void invalid_utf32_code_point(::boost::uint32_t val) { #ifndef BOOST_NO_STD_LOCALE @@ -124,6 +128,9 @@ inline void invalid_utf32_code_point(::boost::uint32_t val) #endif boost::throw_exception(e); } +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif } // namespace detail @@ -296,6 +303,34 @@ public: { m_value = pending_read; } + // + // Range checked version: + // + u16_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b) + { + m_value = pending_read; + // + // The range must not start with a low surrogate, or end in a high surrogate, + // otherwise we run the risk of running outside the underlying input range. + // Likewise b must not be located at a low surrogate. + // + boost::uint16_t val; + if(start != end) + { + if((b != start) && (b != end)) + { + val = *b; + if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u)) + invalid_code_point(val); + } + val = *start; + if(detail::is_surrogate(val) && ((val & 0xFC00u) == 0xDC00u)) + invalid_code_point(val); + val = *--end; + if(detail::is_high_surrogate(val)) + invalid_code_point(val); + } + } private: static void invalid_code_point(::boost::uint16_t val) { @@ -497,7 +532,7 @@ public: while((*--m_position & 0xC0u) == 0x80u) ++count; // now check that the sequence was valid: if(count != detail::utf8_trailing_byte_count(*m_position)) - invalid_sequnce(); + invalid_sequence(); m_value = pending_read; } BaseIterator base()const @@ -513,8 +548,37 @@ public: { m_value = pending_read; } + // + // Checked constructor: + // + u8_to_u32_iterator(BaseIterator b, BaseIterator start, BaseIterator end) : m_position(b) + { + m_value = pending_read; + // + // We must not start with a continuation character, or end with a + // truncated UTF-8 sequence otherwise we run the risk of going past + // the start/end of the underlying sequence: + // + if(start != end) + { + unsigned char v = *start; + if((v & 0xC0u) == 0x80u) + invalid_sequence(); + if((b != start) && (b != end) && ((*b & 0xC0u) == 0x80u)) + invalid_sequence(); + BaseIterator pos = end; + do + { + v = *--pos; + } + while((start != pos) && ((v & 0xC0u) == 0x80u)); + std::ptrdiff_t extra = detail::utf8_byte_count(v); + if(std::distance(pos, end) < extra) + invalid_sequence(); + } + } private: - static void invalid_sequnce() + static void invalid_sequence() { std::out_of_range e("Invalid UTF-8 sequence encountered while trying to encode UTF-32 character"); boost::throw_exception(e); @@ -524,7 +588,7 @@ private: m_value = static_cast<U32Type>(static_cast< ::boost::uint8_t>(*m_position)); // we must not have a continuation character: if((m_value & 0xC0u) == 0x80u) - invalid_sequnce(); + invalid_sequence(); // see how many extra byts we have: unsigned extra = detail::utf8_trailing_byte_count(*m_position); // extract the extra bits, 6 from each extra byte: @@ -547,7 +611,7 @@ private: m_value &= masks[extra]; // check the result: if(m_value > static_cast<U32Type>(0x10FFFFu)) - invalid_sequnce(); + invalid_sequence(); } BaseIterator m_position; mutable U32Type m_value; |