From ed6115361006240e3c7b02295599e4534cc55a13 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 19 Oct 2013 08:57:20 +0200 Subject: Update internal Boost subset to 1.54.0 --- cutl/details/boost/regex/config.hpp | 11 +- cutl/details/boost/regex/icu.hpp | 34 +++--- cutl/details/boost/regex/pending/object_cache.hpp | 4 +- cutl/details/boost/regex/pending/static_mutex.hpp | 15 ++- .../boost/regex/pending/unicode_iterator.hpp | 102 +++++++++++++++-- cutl/details/boost/regex/src/c_regex_traits.cxx | 21 +--- cutl/details/boost/regex/src/cregex.cxx | 17 ++- cutl/details/boost/regex/src/fileiter.cxx | 12 +- cutl/details/boost/regex/src/internals.hpp | 35 ++++++ cutl/details/boost/regex/src/posix_api.cxx | 11 +- cutl/details/boost/regex/src/regex.cxx | 1 + cutl/details/boost/regex/src/regex_raw_buffer.cxx | 4 +- cutl/details/boost/regex/src/w32_regex_traits.cxx | 12 +- cutl/details/boost/regex/src/wc_regex_traits.cxx | 21 +--- cutl/details/boost/regex/src/wide_posix_api.cxx | 16 +-- cutl/details/boost/regex/user.hpp | 3 + cutl/details/boost/regex/v4/basic_regex.hpp | 19 ++-- .../details/boost/regex/v4/basic_regex_creator.hpp | 107 ++++++++++-------- cutl/details/boost/regex/v4/basic_regex_parser.hpp | 125 +++++++++++++++------ cutl/details/boost/regex/v4/cpp_regex_traits.hpp | 17 ++- cutl/details/boost/regex/v4/instances.hpp | 7 +- cutl/details/boost/regex/v4/match_results.hpp | 5 +- cutl/details/boost/regex/v4/perl_matcher.hpp | 5 +- .../details/boost/regex/v4/perl_matcher_common.hpp | 6 + .../boost/regex/v4/perl_matcher_non_recursive.hpp | 11 +- cutl/details/boost/regex/v4/regex_format.hpp | 25 ++++- cutl/details/boost/regex/v4/regex_iterator.hpp | 2 +- cutl/details/boost/regex/v4/regex_split.hpp | 2 +- .../boost/regex/v4/regex_traits_defaults.hpp | 34 +++--- .../boost/regex/v4/u32regex_token_iterator.hpp | 6 +- 30 files changed, 464 insertions(+), 226 deletions(-) create mode 100644 cutl/details/boost/regex/src/internals.hpp (limited to 'cutl/details/boost/regex') diff --git a/cutl/details/boost/regex/config.hpp b/cutl/details/boost/regex/config.hpp index dd28408..a1495ae 100644 --- a/cutl/details/boost/regex/config.hpp +++ b/cutl/details/boost/regex/config.hpp @@ -163,12 +163,17 @@ * with MSVC and the /Zc:wchar_t option we place some extra unsigned short versions * of the non-inline functions in the library, so that users can still link to the lib, * irrespective of whether their own code is built with /Zc:wchar_t. + * Note that this does NOT WORK with VC10 when the C++ locale is in effect as + * the locale's facets simply do not compile in that case. */ -#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && !defined(BOOST_RWSTD_VER) +#if defined(__cplusplus) && (defined(BOOST_MSVC) || defined(__ICL)) && !defined(BOOST_NO_INTRINSIC_WCHAR_T) && defined(BOOST_WINDOWS) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && !defined(BOOST_RWSTD_VER) && ((_MSC_VER < 1600) || !defined(BOOST_REGEX_USE_CPP_LOCALE)) # define BOOST_REGEX_HAS_OTHER_WCHAR_T # ifdef BOOST_MSVC # pragma warning(push) -# pragma warning(disable : 4251 4231 4660) +# pragma warning(disable : 4251 4231) +# if BOOST_MSVC < 1600 +# pragma warning(disable : 4660) +# endif # endif # if defined(_DLL) && defined(BOOST_MSVC) && (BOOST_MSVC < 1600) # include @@ -220,7 +225,7 @@ ****************************************************************************/ #if defined(BOOST_MSVC) && (BOOST_MSVC >= 1200) && defined(_MSC_EXTENSIONS) -#if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) +#if defined(_DEBUG) || defined(__MSVC_RUNTIME_CHECKS) || defined(_MANAGED) || defined(BOOST_REGEX_NO_FASTCALL) # define BOOST_REGEX_CALL __cdecl #else # define BOOST_REGEX_CALL __fastcall diff --git a/cutl/details/boost/regex/icu.hpp b/cutl/details/boost/regex/icu.hpp index 02b6085..7c45c76 100644 --- a/cutl/details/boost/regex/icu.hpp +++ b/cutl/details/boost/regex/icu.hpp @@ -251,7 +251,7 @@ inline u32regex do_make_u32regex(InputIterator i, const cutl_details_boost::mpl::int_<1>*) { typedef cutl_details_boost::u8_to_u32_iterator conv_type; - return u32regex(conv_type(i), conv_type(j), opt); + return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt); } template @@ -261,7 +261,7 @@ inline u32regex do_make_u32regex(InputIterator i, const cutl_details_boost::mpl::int_<2>*) { typedef cutl_details_boost::u16_to_u32_iterator conv_type; - return u32regex(conv_type(i), conv_type(j), opt); + return u32regex(conv_type(i, i, j), conv_type(j, i, j), opt); } template @@ -282,7 +282,7 @@ inline u32regex do_make_u32regex(InputIterator i, typedef cutl_details_boost::u8_to_u32_iterator conv_type; typedef std::vector vector_type; vector_type v; - conv_type a(i), b(j); + conv_type a(i, i, j), b(j, i, j); while(a != b) { v.push_back(*a); @@ -302,7 +302,7 @@ inline u32regex do_make_u32regex(InputIterator i, typedef cutl_details_boost::u16_to_u32_iterator conv_type; typedef std::vector vector_type; vector_type v; - conv_type a(i), b(j); + conv_type a(i, i, j), b(j, i, j); while(a != b) { v.push_back(*a); @@ -423,9 +423,9 @@ bool do_regex_match(BidiIterator first, BidiIterator last, { typedef u16_to_u32_iterator conv_type; typedef match_results match_type; - typedef typename match_type::allocator_type alloc_type; + //typedef typename match_type::allocator_type alloc_type; match_type what; - bool result = ::cutl_details_boost::regex_match(conv_type(first), conv_type(last), what, e, flags); + bool result = ::cutl_details_boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags); // copy results across to m: if(result) copy_results(m, what); return result; @@ -439,9 +439,9 @@ bool do_regex_match(BidiIterator first, BidiIterator last, { typedef u8_to_u32_iterator conv_type; typedef match_results match_type; - typedef typename match_type::allocator_type alloc_type; + //typedef typename match_type::allocator_type alloc_type; match_type what; - bool result = ::cutl_details_boost::regex_match(conv_type(first), conv_type(last), what, e, flags); + bool result = ::cutl_details_boost::regex_match(conv_type(first, first, last), conv_type(last, first, last), what, e, flags); // copy results across to m: if(result) copy_results(m, what); return result; @@ -598,9 +598,9 @@ bool do_regex_search(BidiIterator first, BidiIterator last, { typedef u16_to_u32_iterator conv_type; typedef match_results match_type; - typedef typename match_type::allocator_type alloc_type; + //typedef typename match_type::allocator_type alloc_type; match_type what; - bool result = ::cutl_details_boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base)); + bool result = ::cutl_details_boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base)); // copy results across to m: if(result) copy_results(m, what); return result; @@ -615,9 +615,9 @@ bool do_regex_search(BidiIterator first, BidiIterator last, { typedef u8_to_u32_iterator conv_type; typedef match_results match_type; - typedef typename match_type::allocator_type alloc_type; + //typedef typename match_type::allocator_type alloc_type; match_type what; - bool result = ::cutl_details_boost::regex_search(conv_type(first), conv_type(last), what, e, flags, conv_type(base)); + bool result = ::cutl_details_boost::regex_search(conv_type(first, first, last), conv_type(last, first, last), what, e, flags, conv_type(base)); // copy results across to m: if(result) copy_results(m, what); return result; @@ -764,13 +764,13 @@ template inline std::pair< cutl_details_boost::u8_to_u32_iterator, cutl_details_boost::u8_to_u32_iterator > make_utf32_seq(I i, I j, mpl::int_<1> const*) { - return std::pair< cutl_details_boost::u8_to_u32_iterator, cutl_details_boost::u8_to_u32_iterator >(cutl_details_boost::u8_to_u32_iterator(i), cutl_details_boost::u8_to_u32_iterator(j)); + return std::pair< cutl_details_boost::u8_to_u32_iterator, cutl_details_boost::u8_to_u32_iterator >(cutl_details_boost::u8_to_u32_iterator(i, i, j), cutl_details_boost::u8_to_u32_iterator(j, i, j)); } template inline std::pair< cutl_details_boost::u16_to_u32_iterator, cutl_details_boost::u16_to_u32_iterator > make_utf32_seq(I i, I j, mpl::int_<2> const*) { - return std::pair< cutl_details_boost::u16_to_u32_iterator, cutl_details_boost::u16_to_u32_iterator >(cutl_details_boost::u16_to_u32_iterator(i), cutl_details_boost::u16_to_u32_iterator(j)); + return std::pair< cutl_details_boost::u16_to_u32_iterator, cutl_details_boost::u16_to_u32_iterator >(cutl_details_boost::u16_to_u32_iterator(i, i, j), cutl_details_boost::u16_to_u32_iterator(j, i, j)); } template inline std::pair< I, I > @@ -782,13 +782,15 @@ template inline std::pair< cutl_details_boost::u8_to_u32_iterator, cutl_details_boost::u8_to_u32_iterator > make_utf32_seq(const charT* p, mpl::int_<1> const*) { - return std::pair< cutl_details_boost::u8_to_u32_iterator, cutl_details_boost::u8_to_u32_iterator >(cutl_details_boost::u8_to_u32_iterator(p), cutl_details_boost::u8_to_u32_iterator(p+std::strlen((const char*)p))); + std::size_t len = std::strlen((const char*)p); + return std::pair< cutl_details_boost::u8_to_u32_iterator, cutl_details_boost::u8_to_u32_iterator >(cutl_details_boost::u8_to_u32_iterator(p, p, p+len), cutl_details_boost::u8_to_u32_iterator(p+len, p, p+len)); } template inline std::pair< cutl_details_boost::u16_to_u32_iterator, cutl_details_boost::u16_to_u32_iterator > make_utf32_seq(const charT* p, mpl::int_<2> const*) { - return std::pair< cutl_details_boost::u16_to_u32_iterator, cutl_details_boost::u16_to_u32_iterator >(cutl_details_boost::u16_to_u32_iterator(p), cutl_details_boost::u16_to_u32_iterator(p+u_strlen((const UChar*)p))); + std::size_t len = u_strlen((const UChar*)p); + return std::pair< cutl_details_boost::u16_to_u32_iterator, cutl_details_boost::u16_to_u32_iterator >(cutl_details_boost::u16_to_u32_iterator(p, p, p + len), cutl_details_boost::u16_to_u32_iterator(p+len, p, p + len)); } template inline std::pair< const charT*, const charT* > diff --git a/cutl/details/boost/regex/pending/object_cache.hpp b/cutl/details/boost/regex/pending/object_cache.hpp index 7a213a9..2bf2754 100644 --- a/cutl/details/boost/regex/pending/object_cache.hpp +++ b/cutl/details/boost/regex/pending/object_cache.hpp @@ -73,7 +73,7 @@ cutl_details_boost::shared_ptr object_cache::get(cons // for now just throw, but we should never really get here... // ::cutl_details_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 cutl_details_boost::shared_ptr(); #endif #else @@ -151,7 +151,7 @@ cutl_details_boost::shared_ptr object_cache::do_get(c --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/cutl/details/boost/regex/pending/static_mutex.hpp b/cutl/details/boost/regex/pending/static_mutex.hpp index 8413a56..d3a0307 100644 --- a/cutl/details/boost/regex/pending/static_mutex.hpp +++ b/cutl/details/boost/regex/pending/static_mutex.hpp @@ -36,14 +36,7 @@ // namespace cutl_details_boost{ -class BOOST_REGEX_DECL scoped_static_mutex_lock; - -class static_mutex -{ -public: - typedef scoped_static_mutex_lock scoped_lock; - pthread_mutex_t m_mutex; -}; +class static_mutex; #define BOOST_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER, } @@ -67,6 +60,12 @@ private: bool m_have_lock; }; +class static_mutex +{ +public: + typedef scoped_static_mutex_lock scoped_lock; + pthread_mutex_t m_mutex; +}; } // namespace cutl_details_boost #elif defined(BOOST_HAS_WINTHREADS) diff --git a/cutl/details/boost/regex/pending/unicode_iterator.hpp b/cutl/details/boost/regex/pending/unicode_iterator.hpp index 2ab88c3..467afc7 100644 --- a/cutl/details/boost/regex/pending/unicode_iterator.hpp +++ b/cutl/details/boost/regex/pending/unicode_iterator.hpp @@ -82,16 +82,16 @@ static const ::cutl_details_boost::uint32_t ten_bit_mask = 0x3FFu; inline bool is_high_surrogate(::cutl_details_boost::uint16_t v) { - return (v & 0xFC00u) == 0xd800u; + return (v & 0xFFFFFC00u) == 0xd800u; } inline bool is_low_surrogate(::cutl_details_boost::uint16_t v) { - return (v & 0xFC00u) == 0xdc00u; + return (v & 0xFFFFFC00u) == 0xdc00u; } template inline bool is_surrogate(T v) { - return (v & 0xF800u) == 0xd800; + return (v & 0xFFFFF800u) == 0xd800; } inline unsigned utf8_byte_count(cutl_details_boost::uint8_t c) @@ -113,6 +113,10 @@ inline unsigned utf8_trailing_byte_count(cutl_details_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(::cutl_details_boost::uint32_t val) { #ifndef BOOST_NO_STD_LOCALE @@ -124,6 +128,9 @@ inline void invalid_utf32_code_point(::cutl_details_boost::uint32_t val) #endif cutl_details_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. + // + cutl_details_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(::cutl_details_boost::uint16_t val) { @@ -485,9 +520,26 @@ public: } void increment() { + // We must not start with a continuation character: + if((static_cast(*m_position) & 0xC0) == 0x80) + invalid_sequence(); // skip high surrogate first if there is one: unsigned c = detail::utf8_byte_count(*m_position); - std::advance(m_position, c); + if(m_value == pending_read) + { + // Since we haven't read in a value, we need to validate the code points: + for(unsigned i = 0; i < c; ++i) + { + ++m_position; + // We must have a continuation byte: + if((i != c - 1) && ((static_cast(*m_position) & 0xC0) != 0x80)) + invalid_sequence(); + } + } + else + { + std::advance(m_position, c); + } m_value = pending_read; } void decrement() @@ -497,7 +549,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 +565,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"); cutl_details_boost::throw_exception(e); @@ -524,8 +605,8 @@ private: m_value = static_cast(static_cast< ::cutl_details_boost::uint8_t>(*m_position)); // we must not have a continuation character: if((m_value & 0xC0u) == 0x80u) - invalid_sequnce(); - // see how many extra byts we have: + invalid_sequence(); + // see how many extra bytes we have: unsigned extra = detail::utf8_trailing_byte_count(*m_position); // extract the extra bits, 6 from each extra byte: BaseIterator next(m_position); @@ -533,6 +614,9 @@ private: { ++next; m_value <<= 6; + // We must have a continuation byte: + if((static_cast(*next) & 0xC0) != 0x80) + invalid_sequence(); m_value += static_cast(*next) & 0x3Fu; } // we now need to remove a few of the leftmost bits, but how many depends @@ -547,7 +631,7 @@ private: m_value &= masks[extra]; // check the result: if(m_value > static_cast(0x10FFFFu)) - invalid_sequnce(); + invalid_sequence(); } BaseIterator m_position; mutable U32Type m_value; diff --git a/cutl/details/boost/regex/src/c_regex_traits.cxx b/cutl/details/boost/regex/src/c_regex_traits.cxx index b0f3a47..126e95c 100644 --- a/cutl/details/boost/regex/src/c_regex_traits.cxx +++ b/cutl/details/boost/regex/src/c_regex_traits.cxx @@ -21,6 +21,7 @@ #include #include +#include "internals.hpp" #if !BOOST_WORKAROUND(__BORLANDC__, < 0x560) @@ -107,26 +108,6 @@ c_regex_traits::string_type BOOST_REGEX_CALL c_regex_traits::transfo return result; } -enum -{ - char_class_space=1<<0, - char_class_print=1<<1, - char_class_cntrl=1<<2, - char_class_upper=1<<3, - char_class_lower=1<<4, - char_class_alpha=1<<5, - char_class_digit=1<<6, - char_class_punct=1<<7, - char_class_xdigit=1<<8, - char_class_alnum=char_class_alpha|char_class_digit, - char_class_graph=char_class_alnum|char_class_punct, - char_class_blank=1<<9, - char_class_word=1<<10, - char_class_unicode=1<<11, - char_class_horizontal=1<<12, - char_class_vertical=1<<13 -}; - c_regex_traits::char_class_type BOOST_REGEX_CALL c_regex_traits::lookup_classname(const char* p1, const char* p2) { static const char_class_type masks[] = diff --git a/cutl/details/boost/regex/src/cregex.cxx b/cutl/details/boost/regex/src/cregex.cxx index cf8154f..c64f993 100644 --- a/cutl/details/boost/regex/src/cregex.cxx +++ b/cutl/details/boost/regex/src/cregex.cxx @@ -361,11 +361,24 @@ void BuildFileList(std::list* pl, const char* files, bool recurse) while(dstart != dend) { + // Verify that sprintf will not overflow: + if(std::strlen(dstart.path()) + std::strlen(directory_iterator::separator()) + std::strlen(ptr) >= MAX_PATH) + { + // Oops overflow, skip this item: + ++dstart; + continue; + } #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) - (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); + int r = (::sprintf_s)(buf, sizeof(buf), "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); #else - (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); + int r = (std::sprintf)(buf, "%s%s%s", dstart.path(), directory_iterator::separator(), ptr); #endif + if(r < 0) + { + // sprintf failed, skip this item: + ++dstart; + continue; + } BuildFileList(pl, buf, recurse); ++dstart; } diff --git a/cutl/details/boost/regex/src/fileiter.cxx b/cutl/details/boost/regex/src/fileiter.cxx index 0a669a8..9a99222 100644 --- a/cutl/details/boost/regex/src/fileiter.cxx +++ b/cutl/details/boost/regex/src/fileiter.cxx @@ -19,6 +19,7 @@ #define BOOST_REGEX_SOURCE +#include #include #include #include @@ -847,10 +848,16 @@ bool iswild(const char* mask, const char* name) unsigned _fi_attributes(const char* root, const char* name) { char buf[MAX_PATH]; + // verify that we can not overflow: + if(std::strlen(root) + std::strlen(_fi_sep) + std::strlen(name) >= MAX_PATH) + return 0; + int r; if( ( (root[0] == *_fi_sep) || (root[0] == *_fi_sep_alt) ) && (root[1] == '\0') ) - (std::sprintf)(buf, "%s%s", root, name); + r = (std::sprintf)(buf, "%s%s", root, name); else - (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name); + r = (std::sprintf)(buf, "%s%s%s", root, _fi_sep, name); + if(r < 0) + return 0; // sprintf failed DIR* d = opendir(buf); if(d) { @@ -870,6 +877,7 @@ _fi_find_handle _fi_FindFirstFile(const char* lpFileName, _fi_find_data* lpFindF { if(_fi_FindNextFile(dat, lpFindFileData)) return dat; + closedir(h); } delete dat; return 0; diff --git a/cutl/details/boost/regex/src/internals.hpp b/cutl/details/boost/regex/src/internals.hpp new file mode 100644 index 0000000..3a15cc6 --- /dev/null +++ b/cutl/details/boost/regex/src/internals.hpp @@ -0,0 +1,35 @@ +/* + * + * Copyright (c) 2011 + * John Maddock + * + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file + * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + * + */ + +#ifndef BOOST_REGEX_SRC_INTERNALS_HPP +#define BOOST_REGEX_SRC_INTERNALS_HPP + +enum +{ + char_class_space=1<<0, + char_class_print=1<<1, + char_class_cntrl=1<<2, + char_class_upper=1<<3, + char_class_lower=1<<4, + char_class_alpha=1<<5, + char_class_digit=1<<6, + char_class_punct=1<<7, + char_class_xdigit=1<<8, + char_class_alnum=char_class_alpha|char_class_digit, + char_class_graph=char_class_alnum|char_class_punct, + char_class_blank=1<<9, + char_class_word=1<<10, + char_class_unicode=1<<11, + char_class_horizontal=1<<12, + char_class_vertical=1<<13 +}; + +#endif // BOOST_REGEX_SRC_INTERNALS_HPP diff --git a/cutl/details/boost/regex/src/posix_api.cxx b/cutl/details/boost/regex/src/posix_api.cxx index 589a235..02d76bf 100644 --- a/cutl/details/boost/regex/src/posix_api.cxx +++ b/cutl/details/boost/regex/src/posix_api.cxx @@ -18,6 +18,7 @@ #define BOOST_REGEX_SOURCE +#include #include #include #include @@ -167,11 +168,17 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorA(int code, const regex_tA* { if(std::strcmp(e->re_endp, names[i]) == 0) { + // + // We're converting an integer i to a string, and since i <= REG_E_UNKNOWN + // a five character string is *always* large enough: + // #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) && !defined(_WIN32_WCE) && !defined(UNDER_CE) - (::sprintf_s)(localbuf, 5, "%d", i); + int r = (::sprintf_s)(localbuf, 5, "%d", i); #else - (std::sprintf)(localbuf, "%d", i); + int r = (std::sprintf)(localbuf, "%d", i); #endif + if(r < 0) + return 0; // sprintf failed if(std::strlen(localbuf) < buf_size) re_detail::strcpy_s(buf, buf_size, localbuf); return std::strlen(localbuf) + 1; diff --git a/cutl/details/boost/regex/src/regex.cxx b/cutl/details/boost/regex/src/regex.cxx index 0f3938e..28f40d0 100644 --- a/cutl/details/boost/regex/src/regex.cxx +++ b/cutl/details/boost/regex/src/regex.cxx @@ -19,6 +19,7 @@ #define BOOST_REGEX_SOURCE +#include #include #include #include diff --git a/cutl/details/boost/regex/src/regex_raw_buffer.cxx b/cutl/details/boost/regex/src/regex_raw_buffer.cxx index a0c4811..7b06725 100644 --- a/cutl/details/boost/regex/src/regex_raw_buffer.cxx +++ b/cutl/details/boost/regex/src/regex_raw_buffer.cxx @@ -18,6 +18,7 @@ #define BOOST_REGEX_SOURCE +#include #include #include #include @@ -45,7 +46,8 @@ void BOOST_REGEX_CALL raw_storage::resize(size_type n) // allocate and copy data: register pointer ptr = static_cast(::operator new(newsize)); BOOST_REGEX_NOEH_ASSERT(ptr) - std::memcpy(ptr, start, datasize); + if(start) + std::memcpy(ptr, start, datasize); // get rid of old buffer: ::operator delete(start); diff --git a/cutl/details/boost/regex/src/w32_regex_traits.cxx b/cutl/details/boost/regex/src/w32_regex_traits.cxx index d17db73..c9d29e8 100644 --- a/cutl/details/boost/regex/src/w32_regex_traits.cxx +++ b/cutl/details/boost/regex/src/w32_regex_traits.cxx @@ -283,9 +283,11 @@ BOOST_REGEX_DECL std::string BOOST_REGEX_CALL w32_cat_get(const cat_type& cat, l if (r == 0) return def; - LPSTR buf = (LPSTR)_alloca( (r + 1) * 2 ); - if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, (r + 1) * 2, NULL, NULL) == 0) - return def; + + int buf_size = 1 + ::WideCharToMultiByte(CP_ACP, 0, wbuf, r, NULL, 0, NULL, NULL); + LPSTR buf = (LPSTR)_alloca(buf_size); + if (::WideCharToMultiByte(CP_ACP, 0, wbuf, r, buf, buf_size, NULL, NULL) == 0) + return def; // failed conversion. #endif return std::string(buf); } @@ -485,7 +487,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_tolower(char c, lcid_type idx) return c; if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0) - return c; + return c; // No single byte lower case equivalent available #endif return result[0]; } @@ -556,7 +558,7 @@ BOOST_REGEX_DECL char BOOST_REGEX_CALL w32_toupper(char c, lcid_type idx) return c; if (::WideCharToMultiByte(code_page, 0, &wide_result, 1, result, 2, NULL, NULL) == 0) - return c; + return c; // No single byte upper case equivalent available. #endif return result[0]; } diff --git a/cutl/details/boost/regex/src/wc_regex_traits.cxx b/cutl/details/boost/regex/src/wc_regex_traits.cxx index 2c6b44b..29d3bd1 100644 --- a/cutl/details/boost/regex/src/wc_regex_traits.cxx +++ b/cutl/details/boost/regex/src/wc_regex_traits.cxx @@ -22,6 +22,7 @@ #include #include #include +#include "internals.hpp" #if defined(_DLL_CPPLIB) && !defined(_M_CEE_PURE) && defined(_NATIVE_WCHAR_T_DEFINED) \ && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) || defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER))\ @@ -147,26 +148,6 @@ c_regex_traits::string_type BOOST_REGEX_CALL c_regex_traits::t return result; } -enum -{ - char_class_space=1<<0, - char_class_print=1<<1, - char_class_cntrl=1<<2, - char_class_upper=1<<3, - char_class_lower=1<<4, - char_class_alpha=1<<5, - char_class_digit=1<<6, - char_class_punct=1<<7, - char_class_xdigit=1<<8, - char_class_alnum=char_class_alpha|char_class_digit, - char_class_graph=char_class_alnum|char_class_punct, - char_class_blank=1<<9, - char_class_word=1<<10, - char_class_unicode=1<<11, - char_class_horizontal=1<<12, - char_class_vertical=1<<13 -}; - c_regex_traits::char_class_type BOOST_REGEX_CALL c_regex_traits::lookup_classname(const wchar_t* p1, const wchar_t* p2) { static const char_class_type masks[] = diff --git a/cutl/details/boost/regex/src/wide_posix_api.cxx b/cutl/details/boost/regex/src/wide_posix_api.cxx index d132480..6c42679 100644 --- a/cutl/details/boost/regex/src/wide_posix_api.cxx +++ b/cutl/details/boost/regex/src/wide_posix_api.cxx @@ -74,7 +74,7 @@ const wchar_t* wnames[] = { }; } -typedef cutl_details_boost::basic_regex > c_regex_type; +typedef cutl_details_boost::basic_regex > wc_regex_type; BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wchar_t* ptr, int f) { @@ -84,7 +84,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha #ifndef BOOST_NO_EXCEPTIONS try{ #endif - expression->guts = new c_regex_type(); + expression->guts = new wc_regex_type(); #ifndef BOOST_NO_EXCEPTIONS } catch(...) { @@ -134,9 +134,9 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regcompW(regex_tW* expression, const wcha try{ #endif expression->re_magic = wmagic_value; - static_cast(expression->guts)->set_expression(ptr, p2, flags); - expression->re_nsub = static_cast(expression->guts)->mark_count() - 1; - result = static_cast(expression->guts)->error_code(); + static_cast(expression->guts)->set_expression(ptr, p2, flags); + expression->re_nsub = static_cast(expression->guts)->mark_count() - 1; + result = static_cast(expression->guts)->error_code(); #ifndef BOOST_NO_EXCEPTIONS } catch(const cutl_details_boost::regex_error& be) @@ -215,7 +215,7 @@ BOOST_REGEX_DECL regsize_t BOOST_REGEX_CCALL regerrorW(int code, const regex_tW* { std::string p; if((e) && (e->re_magic == wmagic_value)) - p = static_cast(e->guts)->get_traits().error_string(static_cast< ::cutl_details_boost::regex_constants::error_type>(code)); + p = static_cast(e->guts)->get_traits().error_string(static_cast< ::cutl_details_boost::regex_constants::error_type>(code)); else { p = re_detail::get_default_error_string(static_cast< ::cutl_details_boost::regex_constants::error_type>(code)); @@ -264,7 +264,7 @@ BOOST_REGEX_DECL int BOOST_REGEX_CCALL regexecW(const regex_tW* expression, cons #endif if(expression->re_magic == wmagic_value) { - result = regex_search(start, end, m, *static_cast(expression->guts), flags); + result = regex_search(start, end, m, *static_cast(expression->guts), flags); } else return result; @@ -301,7 +301,7 @@ BOOST_REGEX_DECL void BOOST_REGEX_CCALL regfreeW(regex_tW* expression) { if(expression->re_magic == wmagic_value) { - delete static_cast(expression->guts); + delete static_cast(expression->guts); } expression->re_magic = 0; } diff --git a/cutl/details/boost/regex/user.hpp b/cutl/details/boost/regex/user.hpp index b4ab5c4..5176b39 100644 --- a/cutl/details/boost/regex/user.hpp +++ b/cutl/details/boost/regex/user.hpp @@ -88,3 +88,6 @@ // define this if you want to enable support for Unicode via ICU. // #define BOOST_HAS_ICU + +// define this if you want regex to use __cdecl calling convensions, even when __fastcall is available: +// #define BOOST_REGEX_NO_FASTCALL diff --git a/cutl/details/boost/regex/v4/basic_regex.hpp b/cutl/details/boost/regex/v4/basic_regex.hpp index d55cea0..e238d25 100644 --- a/cutl/details/boost/regex/v4/basic_regex.hpp +++ b/cutl/details/boost/regex/v4/basic_regex.hpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 1998-2004 - * John Maddock + * Copyright (c) 1998-2004 John Maddock + * Copyright 2011 Garmin Ltd. or its subsidiaries * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -36,7 +36,10 @@ namespace cutl_details_boost{ #ifdef BOOST_MSVC #pragma warning(push) -#pragma warning(disable : 4251 4231 4660 4800) +#pragma warning(disable : 4251 4231 4800) +#if BOOST_MSVC < 1600 +#pragma warning(disable : 4660) +#endif #endif namespace re_detail{ @@ -234,7 +237,7 @@ public: std::pair BOOST_REGEX_CALL subexpression(std::size_t n)const { if(n == 0) - throw std::out_of_range("0 is not a valid subexpression index."); + cutl_details_boost::throw_exception(std::out_of_range("0 is not a valid subexpression index.")); const std::pair& pi = this->m_subs.at(n - 1); std::pair p(expression() + pi.first, expression() + pi.second); return p; @@ -243,11 +246,11 @@ public: // begin, end: const_iterator BOOST_REGEX_CALL begin()const { - return (!this->m_status ? 0 : this->m_expression); + return (this->m_status ? 0 : this->m_expression); } const_iterator BOOST_REGEX_CALL end()const { - return (!this->m_status ? 0 : this->m_expression + this->m_expression_len); + return (this->m_status ? 0 : this->m_expression + this->m_expression_len); } flag_type BOOST_REGEX_CALL flags()const { @@ -398,7 +401,7 @@ public: typedef typename traits::string_type seq_type; seq_type a(arg_first, arg_last); if(a.size()) - assign(&*a.begin(), &*a.begin() + a.size(), f); + assign(static_cast(&*a.begin()), static_cast(&*a.begin() + a.size()), f); else assign(static_cast(0), static_cast(0), f); } @@ -487,7 +490,7 @@ public: std::pair BOOST_REGEX_CALL subexpression(std::size_t n)const { if(!m_pimpl.get()) - throw std::logic_error("Can't access subexpressions in an invalid regex."); + cutl_details_boost::throw_exception(std::logic_error("Can't access subexpressions in an invalid regex.")); return m_pimpl->subexpression(n); } const_iterator BOOST_REGEX_CALL begin()const diff --git a/cutl/details/boost/regex/v4/basic_regex_creator.hpp b/cutl/details/boost/regex/v4/basic_regex_creator.hpp index a4599f1..375d29b 100644 --- a/cutl/details/boost/regex/v4/basic_regex_creator.hpp +++ b/cutl/details/boost/regex/v4/basic_regex_creator.hpp @@ -66,7 +66,7 @@ class basic_char_set public: typedef digraph digraph_type; typedef typename traits::string_type string_type; - typedef typename traits::char_class_type mask_type; + typedef typename traits::char_class_type m_type; basic_char_set() { @@ -100,12 +100,12 @@ public: } m_empty = false; } - void add_class(mask_type m) + void add_class(m_type m) { m_classes |= m; m_empty = false; } - void add_negated_class(mask_type m) + void add_negated_class(m_type m) { m_negated_classes |= m; m_empty = false; @@ -162,11 +162,11 @@ public: { return m_equivalents.end(); } - mask_type classes()const + m_type classes()const { return m_classes; } - mask_type negated_classes()const + m_type negated_classes()const { return m_negated_classes; } @@ -179,8 +179,8 @@ private: std::vector m_ranges; // a list of end points of our ranges bool m_negate; // true if the set is to be negated bool m_has_digraphs; // true if we have digraphs present - mask_type m_classes; // character classes to match - mask_type m_negated_classes; // negated character classes to match + m_type m_classes; // character classes to match + m_type m_negated_classes; // negated character classes to match bool m_empty; // whether we've added anything yet std::vector m_equivalents; // a list of equivalence classes }; @@ -241,6 +241,7 @@ protected: unsigned m_backrefs; // bitmask of permitted backrefs cutl_details_boost::uintmax_t m_bad_repeats; // bitmask of repeats we can't deduce a startmap for; bool m_has_recursions; // set when we have recursive expresisons to fixup + std::vector m_recursion_checks; // notes which recursions we've followed while analysing this expression typename traits::char_class_type m_word_mask; // mask used to determine if a character is a word character typename traits::char_class_type m_mask_space; // mask used to determine if a character is a word character typename traits::char_class_type m_lower_mask; // mask used to determine if a character is a lowercase character @@ -366,9 +367,9 @@ re_syntax_base* basic_regex_creator::append_set( { typedef typename traits::string_type string_type; typedef typename basic_char_set::list_iterator item_iterator; - typedef typename traits::char_class_type mask_type; + typedef typename traits::char_class_type m_type; - re_set_long* result = static_cast*>(append_state(syntax_element_long_set, sizeof(re_set_long))); + re_set_long* result = static_cast*>(append_state(syntax_element_long_set, sizeof(re_set_long))); // // fill in the basics: // @@ -512,28 +513,23 @@ re_syntax_base* basic_regex_creator::append_set( // // finally reset the address of our last state: // - m_last_state = result = static_cast*>(getaddress(offset)); + m_last_state = result = static_cast*>(getaddress(offset)); return result; } -namespace{ - template inline bool char_less(T t1, T t2) { return t1 < t2; } -template<> -inline bool char_less(char t1, char t2) +inline bool char_less(char t1, char t2) { return static_cast(t1) < static_cast(t2); } -template<> -inline bool char_less(signed char t1, signed char t2) +inline bool char_less(signed char t1, signed char t2) { return static_cast(t1) < static_cast(t2); } -} template re_syntax_base* basic_regex_creator::append_set( @@ -597,7 +593,7 @@ re_syntax_base* basic_regex_creator::append_set( } else { - if(char_less(c2, c1)) + if(char_less(c2, c1)) { // Oops error: return 0; @@ -609,8 +605,8 @@ re_syntax_base* basic_regex_creator::append_set( // // and now the classes: // - typedef typename traits::char_class_type mask_type; - mask_type m = char_set.classes(); + typedef typename traits::char_class_type m_type; + m_type m = char_set.classes(); if(flags() & regbase::icase) { // adjust m as needed: @@ -712,6 +708,8 @@ void basic_regex_creator::finalize(const charT* p1, const charT* m_pdata->m_can_be_null = 0; m_bad_repeats = 0; + if(m_has_recursions) + m_recursion_checks.assign(1 + m_pdata->m_mark_count, false); create_startmap(m_pdata->m_first_state, m_pdata->m_startmap, &(m_pdata->m_can_be_null), mask_all); // get the restart type: m_pdata->m_restart_type = get_restart_type(m_pdata->m_first_state); @@ -740,14 +738,14 @@ void basic_regex_creator::fixup_pointers(re_syntax_base* state) case syntax_element_long_set_rep: // set the state_id of this repeat: static_cast(state)->state_id = m_repeater_id++; - // fall through: + BOOST_FALLTHROUGH; case syntax_element_alt: std::memset(static_cast(state)->_map, 0, sizeof(static_cast(state)->_map)); static_cast(state)->can_be_null = 0; - // fall through: + BOOST_FALLTHROUGH; case syntax_element_jump: static_cast(state)->alt.p = getaddress(static_cast(state)->alt.i, state); - // fall through again: + BOOST_FALLTHROUGH; default: if(state->next.i) state->next.p = getaddress(state->next.i, state); @@ -879,6 +877,7 @@ void basic_regex_creator::fixup_recursions(re_syntax_base* state) } } } + break; default: break; } @@ -943,14 +942,19 @@ void basic_regex_creator::create_startmaps(re_syntax_base* state) e.raise(); } } - // fall through: + BOOST_FALLTHROUGH; default: state = state->next.p; } } + // now work through our list, building all the maps as we go: while(v.size()) { + // Initialize m_recursion_checks if we need it: + if(m_has_recursions) + m_recursion_checks.assign(1 + m_pdata->m_mark_count, false); + const std::pair& p = v.back(); m_icase = p.first; state = p.second; @@ -960,6 +964,9 @@ void basic_regex_creator::create_startmaps(re_syntax_base* state) m_bad_repeats = 0; create_startmap(state->next.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_take); m_bad_repeats = 0; + + if(m_has_recursions) + m_recursion_checks.assign(1 + m_pdata->m_mark_count, false); create_startmap(static_cast(state)->alt.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_skip); // adjust the type of the state to allow for faster matching: state->type = this->get_repeat_type(state); @@ -971,7 +978,7 @@ void basic_regex_creator::create_startmaps(re_syntax_base* state) template int basic_regex_creator::calculate_backstep(re_syntax_base* state) { - typedef typename traits::char_class_type mask_type; + typedef typename traits::char_class_type m_type; int result = 0; while(state) { @@ -1024,10 +1031,10 @@ int basic_regex_creator::calculate_backstep(re_syntax_base* state state = rep->alt.p; continue; } - else if((state->type == syntax_element_long_set_rep)) + else if(state->type == syntax_element_long_set_rep) { BOOST_ASSERT(rep->next.p->type == syntax_element_long_set); - if(static_cast*>(rep->next.p)->singleton == 0) + if(static_cast*>(rep->next.p)->singleton == 0) return -1; if(rep->max != rep->min) return -1; @@ -1038,7 +1045,7 @@ int basic_regex_creator::calculate_backstep(re_syntax_base* state } return -1; case syntax_element_long_set: - if(static_cast*>(state)->singleton == 0) + if(static_cast*>(state)->singleton == 0) return -1; result += 1; break; @@ -1102,9 +1109,9 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, if(l_map) { l_map[0] |= mask_init; - l_map['\n'] |= mask; - l_map['\r'] |= mask; - l_map['\f'] |= mask; + l_map[static_cast('\n')] |= mask; + l_map[static_cast('\r')] |= mask; + l_map[static_cast('\f')] |= mask; l_map[0x85] |= mask; } // now figure out if we can match a NULL string at this point: @@ -1114,7 +1121,11 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, } case syntax_element_recurse: { - if(recursion_start == state) + if(state->type == syntax_element_startmark) + recursion_sub = static_cast(state)->index; + else + recursion_sub = 0; + if(m_recursion_checks[recursion_sub]) { // Infinite recursion!! if(0 == this->m_pdata->m_status) // update the error code if not already set @@ -1139,19 +1150,18 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, recursion_start = state; recursion_restart = state->next.p; state = static_cast(state)->alt.p; - if(state->type == syntax_element_startmark) - recursion_sub = static_cast(state)->index; - else - recursion_sub = 0; + m_recursion_checks[recursion_sub] = true; break; } - // fall through, can't handle nested recursion here... + m_recursion_checks[recursion_sub] = true; + // can't handle nested recursion here... + BOOST_FALLTHROUGH; } case syntax_element_backref: // can be null, and any character can match: if(pnull) *pnull |= mask; - // fall through: + BOOST_FALLTHROUGH; case syntax_element_wild: { // can't be null, any character can match: @@ -1206,14 +1216,14 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, case syntax_element_long_set: if(l_map) { - typedef typename traits::char_class_type mask_type; - if(static_cast*>(state)->singleton) + typedef typename traits::char_class_type m_type; + if(static_cast*>(state)->singleton) { l_map[0] |= mask_init; for(unsigned int i = 0; i < (1u << CHAR_BIT); ++i) { charT c = static_cast(i); - if(&c != re_is_set_member(&c, &c + 1, static_cast*>(state), *m_pdata, m_icase)) + if(&c != re_is_set_member(&c, &c + 1, static_cast*>(state), *m_pdata, l_icase)) l_map[i] |= mask; } } @@ -1289,8 +1299,8 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, if(l_map) { l_map[0] |= mask_init; - l_map['\n'] |= mask; - l_map['\r'] |= mask; + l_map[static_cast('\n')] |= mask; + l_map[static_cast('\r')] |= mask; } if(pnull) *pnull |= mask; @@ -1325,7 +1335,7 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, re_syntax_base* p = m_pdata->m_first_state; while(p) { - if((p->type == syntax_element_recurse)) + if(p->type == syntax_element_recurse) { re_brace* p2 = static_cast(static_cast(p)->alt.p); if((p2->type == syntax_element_startmark) && (p2->index == static_cast(state)->index)) @@ -1351,7 +1361,7 @@ void basic_regex_creator::create_startmap(re_syntax_base* state, state = state->next.p->next.p; break; } - // otherwise fall through: + BOOST_FALLTHROUGH; default: state = state->next.p; } @@ -1448,6 +1458,7 @@ void basic_regex_creator::set_bad_repeat(re_syntax_base* pt) if(state_id <= sizeof(m_bad_repeats) * CHAR_BIT) m_bad_repeats |= (one << state_id); } + break; default: break; } @@ -1456,7 +1467,7 @@ void basic_regex_creator::set_bad_repeat(re_syntax_base* pt) template syntax_element_type basic_regex_creator::get_repeat_type(re_syntax_base* state) { - typedef typename traits::char_class_type mask_type; + typedef typename traits::char_class_type m_type; if(state->type == syntax_element_rep) { // check to see if we are repeating a single state: @@ -1471,7 +1482,7 @@ syntax_element_type basic_regex_creator::get_repeat_type(re_synta case re_detail::syntax_element_set: return re_detail::syntax_element_short_set_rep; case re_detail::syntax_element_long_set: - if(static_cast*>(state->next.p)->singleton) + if(static_cast*>(state->next.p)->singleton) return re_detail::syntax_element_long_set_rep; break; default: @@ -1529,7 +1540,7 @@ void basic_regex_creator::probe_leading_repeat(re_syntax_base* st case syntax_element_long_set_rep: if(this->m_has_backrefs == 0) static_cast(state)->leading = true; - // fall through: + BOOST_FALLTHROUGH; default: return; } diff --git a/cutl/details/boost/regex/v4/basic_regex_parser.hpp b/cutl/details/boost/regex/v4/basic_regex_parser.hpp index 63475e8..9182da2 100644 --- a/cutl/details/boost/regex/v4/basic_regex_parser.hpp +++ b/cutl/details/boost/regex/v4/basic_regex_parser.hpp @@ -191,6 +191,7 @@ void basic_regex_parser::fail(regex_constants::error_type error_c this->m_pdata->m_status = error_code; m_position = m_end; // don't bother parsing anything else +#ifndef BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS // // Augment error message with the regular expression text: // @@ -200,9 +201,9 @@ void basic_regex_parser::fail(regex_constants::error_type error_c if(error_code != regex_constants::error_empty) { if((start_pos != 0) || (end_pos != (m_end - m_base))) - message += " The error occured while parsing the regular expression fragment: '"; + message += " The error occurred while parsing the regular expression fragment: '"; else - message += " The error occured while parsing the regular expression: '"; + message += " The error occurred while parsing the regular expression: '"; if(start_pos != end_pos) { message += std::string(m_base + start_pos, m_base + position); @@ -211,6 +212,7 @@ void basic_regex_parser::fail(regex_constants::error_type error_c } message += "'."; } +#endif #ifndef BOOST_NO_EXCEPTIONS if(0 == (this->flags() & regex_constants::no_except)) @@ -367,7 +369,7 @@ bool basic_regex_parser::parse_extended() while((m_position != m_end) && !is_separator(*m_position++)){} return true; } - // Otherwise fall through: + BOOST_FALLTHROUGH; default: result = parse_literal(); break; @@ -621,7 +623,7 @@ bool basic_regex_parser::parse_basic_escape() { case 'w': negate = false; - // fall through: + BOOST_FALLTHROUGH; case 'W': { basic_char_set char_set; @@ -638,7 +640,7 @@ bool basic_regex_parser::parse_basic_escape() } case 's': negate = false; - // fall through: + BOOST_FALLTHROUGH; case 'S': return add_emacs_code(negate); case 'c': @@ -660,17 +662,22 @@ template bool basic_regex_parser::parse_extended_escape() { ++m_position; + if(m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base, "Incomplete escape sequence found."); + return false; + } bool negate = false; // in case this is a character class escape: \w \d etc switch(this->m_traits.escape_syntax_type(*m_position)) { case regex_constants::escape_type_not_class: negate = true; - // fall through: + BOOST_FALLTHROUGH; case regex_constants::escape_type_class: { escape_type_class_jump: - typedef typename traits::char_class_type mask_type; - mask_type m = this->m_traits.lookup_classname(m_position, m_position+1); + typedef typename traits::char_class_type m_type; + m_type m = this->m_traits.lookup_classname(m_position, m_position+1); if(m != 0) { basic_char_set char_set; @@ -735,7 +742,7 @@ escape_type_class_jump: break; case regex_constants::escape_type_not_property: negate = true; - // fall through: + BOOST_FALLTHROUGH; case regex_constants::escape_type_property: { ++m_position; @@ -894,7 +901,7 @@ escape_type_class_jump: case regex_constants::escape_type_control_v: if(0 == (this->flags() & (regbase::main_option_type | regbase::no_perl_ex))) goto escape_type_class_jump; - // fallthrough: + BOOST_FALLTHROUGH; default: this->append_literal(unescape_character()); break; @@ -941,7 +948,8 @@ bool basic_regex_parser::parse_repeat(std::size_t low, std::size_ ++m_position; } // for perl regexes only check for pocessive ++ repeats. - if((0 == (this->flags() & regbase::main_option_type)) + if((m_position != m_end) + && (0 == (this->flags() & regbase::main_option_type)) && (this->m_traits.syntax_type(*m_position) == regex_constants::syntax_plus)) { pocessive = true; @@ -1025,13 +1033,14 @@ bool basic_regex_parser::parse_repeat(std::size_t low, std::size_ { // // Check for illegal following quantifier, we have to do this here, because - // the extra states we insert below circumvents are usual error checking :-( + // the extra states we insert below circumvents our usual error checking :-( // switch(this->m_traits.syntax_type(*m_position)) { case regex_constants::syntax_star: case regex_constants::syntax_plus: case regex_constants::syntax_question: + case regex_constants::syntax_open_brace: fail(regex_constants::error_badrepeat, m_position - m_base); return false; } @@ -1061,26 +1070,46 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) // skip whitespace: while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) ++m_position; - // fail if at end: if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); - return false; + if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex)) + { + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); + return false; + } + // Treat the opening '{' as a literal character, rewind to start of error: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position; + return parse_literal(); } // get min: v = this->m_traits.toi(m_position, m_end, 10); // skip whitespace: - while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) - ++m_position; if(v < 0) { - fail(regex_constants::error_badbrace, this->m_position - this->m_base); - return false; + if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex)) + { + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); + return false; + } + // Treat the opening '{' as a literal character, rewind to start of error: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position; + return parse_literal(); } - else if(this->m_position == this->m_end) + while((m_position != m_end) && this->m_traits.isctype(*m_position, this->m_mask_space)) + ++m_position; + if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); - return false; + if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex)) + { + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); + return false; + } + // Treat the opening '{' as a literal character, rewind to start of error: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position; + return parse_literal(); } min = v; // see if we have a comma: @@ -1093,12 +1122,19 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) ++m_position; if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); - return false; + if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex)) + { + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); + return false; + } + // Treat the opening '{' as a literal character, rewind to start of error: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position; + return parse_literal(); } // get the value if any: v = this->m_traits.toi(m_position, m_end, 10); - max = (v >= 0) ? v : (std::numeric_limits::max)(); + max = (v >= 0) ? (std::size_t)v : (std::numeric_limits::max)(); } else { @@ -1111,8 +1147,15 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) // OK now check trailing }: if(this->m_position == this->m_end) { - fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); - return false; + if(this->flags() & (regbase::main_option_type | regbase::no_perl_ex)) + { + fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); + return false; + } + // Treat the opening '{' as a literal character, rewind to start of error: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position; + return parse_literal(); } if(isbasic) { @@ -1135,8 +1178,10 @@ bool basic_regex_parser::parse_repeat_range(bool isbasic) ++m_position; else { - fail(regex_constants::error_brace, this->m_position - this->m_base, incomplete_message); - return false; + // Treat the opening '{' as a literal character, rewind to start of error: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_brace) --m_position; + return parse_literal(); } // // finally go and add the repeat, unless error: @@ -1381,8 +1426,8 @@ bool basic_regex_parser::parse_inner_set(basic_char_setm_traits.lookup_classname(name_first, name_last); + typedef typename traits::char_class_type m_type; + m_type m = this->m_traits.lookup_classname(name_first, name_last); if(m == 0) { if(char_set.empty() && (name_last - name_first == 1)) @@ -1950,7 +1995,7 @@ bool basic_regex_parser::parse_perl_extension() { case regex_constants::syntax_or: m_mark_reset = m_mark_count; - // fall through: + BOOST_FALLTHROUGH; case regex_constants::syntax_colon: // // a non-capturing mark: @@ -2087,6 +2132,14 @@ insert_recursion: return false; } v = this->m_traits.toi(m_position, m_end, 10); + if(m_position == m_end) + { + // Rewind to start of (? sequence: + --m_position; + while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; + fail(regex_constants::error_perl_extension, m_position - m_base); + return false; + } if(*m_position == charT('R')) { if(++m_position == m_end) @@ -2490,9 +2543,11 @@ option_group_jump: this->m_pdata->m_data.align(); re_jump* jmp = static_cast(this->getaddress(jump_offset)); jmp->alt.i = this->m_pdata->m_data.size() - this->getoffset(jmp); - if(this->m_last_state == jmp) + if((this->m_last_state == jmp) && (markid != -2)) { - // Oops... we didn't have anything inside the assertion: + // Oops... we didn't have anything inside the assertion. + // Note we don't get here for negated forward lookahead as (?!) + // does have some uses. // Rewind to start of (? sequence: --m_position; while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position; @@ -2711,6 +2766,8 @@ regex_constants::syntax_option_type basic_regex_parser::parse_opt } } while(!breakout); + + breakout = false; if(*m_position == static_cast('-')) { diff --git a/cutl/details/boost/regex/v4/cpp_regex_traits.hpp b/cutl/details/boost/regex/v4/cpp_regex_traits.hpp index 7281e84..654f668 100644 --- a/cutl/details/boost/regex/v4/cpp_regex_traits.hpp +++ b/cutl/details/boost/regex/v4/cpp_regex_traits.hpp @@ -1,7 +1,7 @@ /* * - * Copyright (c) 2004 - * John Maddock + * Copyright (c) 2004 John Maddock + * Copyright 2011 Garmin Ltd. or its subsidiaries * * Use, modification and distribution are subject to the * Boost Software License, Version 1.0. (See accompanying file @@ -20,6 +20,7 @@ #define BOOST_CPP_REGEX_TRAITS_HPP_INCLUDED #include +#include #ifndef BOOST_NO_STD_LOCALE @@ -107,12 +108,14 @@ template typename parser_buf::pos_type parser_buf::seekoff(off_type off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which) { + typedef typename cutl_details_boost::int_t::least cast_type; + if(which & ::std::ios_base::out) return pos_type(off_type(-1)); std::ptrdiff_t size = this->egptr() - this->eback(); std::ptrdiff_t pos = this->gptr() - this->eback(); charT* g = this->eback(); - switch(way) + switch(static_cast(way)) { case ::std::ios_base::beg: if((off < 0) || (off > size)) @@ -511,7 +514,9 @@ typename cpp_regex_traits_implementation::string_type // however at least one std lib will always throw // std::bad_alloc for certain arguments... // +#ifndef BOOST_NO_EXCEPTIONS try{ +#endif // // What we do here depends upon the format of the sort key returned by // sort key returned by this->transform: @@ -546,7 +551,9 @@ typename cpp_regex_traits_implementation::string_type result.erase(i); break; } +#ifndef BOOST_NO_EXCEPTIONS }catch(...){} +#endif while(result.size() && (charT(0) == *result.rbegin())) result.erase(result.size() - 1); if(result.empty()) @@ -576,7 +583,9 @@ typename cpp_regex_traits_implementation::string_type // std::bad_alloc for certain arguments... // string_type result; +#ifndef BOOST_NO_EXCEPTIONS try{ +#endif result = this->m_pcollate->transform(p1, p2); // // Borland's STLPort version returns a NULL-terminated @@ -593,10 +602,12 @@ typename cpp_regex_traits_implementation::string_type result.erase(result.size() - 1); #endif BOOST_ASSERT(std::find(result.begin(), result.end(), charT(0)) == result.end()); +#ifndef BOOST_NO_EXCEPTIONS } catch(...) { } +#endif return result; } diff --git a/cutl/details/boost/regex/v4/instances.hpp b/cutl/details/boost/regex/v4/instances.hpp index 0ebf5c9..831d6ad 100644 --- a/cutl/details/boost/regex/v4/instances.hpp +++ b/cutl/details/boost/regex/v4/instances.hpp @@ -84,7 +84,10 @@ template class BOOST_REGEX_DECL ::cutl_details_boost::re_detail::perl_matcher; @@ -118,7 +121,7 @@ template class BOOST_REGEX_TEMPLATE_DECL ::cutl_details_boost::re_detail::perl_m #undef BOOST_REGEX_TEMPLATE_DECL -#elif (defined(__GNUC__) && (__GNUC__ >= 3)) || !defined(BOOST_NO_EXTERN_TEMPLATE) +#elif (defined(__GNUC__) && (__GNUC__ >= 3)) || !defined(BOOST_NO_CXX11_EXTERN_TEMPLATE) # ifndef BOOST_REGEX_INSTANTIATE # ifdef __GNUC__ diff --git a/cutl/details/boost/regex/v4/match_results.hpp b/cutl/details/boost/regex/v4/match_results.hpp index 4cdeb3c..8046cfd 100644 --- a/cutl/details/boost/regex/v4/match_results.hpp +++ b/cutl/details/boost/regex/v4/match_results.hpp @@ -33,7 +33,10 @@ namespace cutl_details_boost{ #ifdef BOOST_MSVC #pragma warning(push) -#pragma warning(disable : 4251 4231 4660) +#pragma warning(disable : 4251 4231) +# if BOOST_MSVC < 1600 +# pragma warning(disable : 4660) +# endif #endif namespace re_detail{ diff --git a/cutl/details/boost/regex/v4/perl_matcher.hpp b/cutl/details/boost/regex/v4/perl_matcher.hpp index 8da8bed..3ef87be 100644 --- a/cutl/details/boost/regex/v4/perl_matcher.hpp +++ b/cutl/details/boost/regex/v4/perl_matcher.hpp @@ -344,7 +344,10 @@ struct recursion_info #ifdef BOOST_MSVC #pragma warning(push) -#pragma warning(disable : 4251 4231 4660) +#pragma warning(disable : 4251 4231) +# if BOOST_MSVC < 1600 +# pragma warning(disable : 4660) +# endif #endif template diff --git a/cutl/details/boost/regex/v4/perl_matcher_common.hpp b/cutl/details/boost/regex/v4/perl_matcher_common.hpp index d7c9a85..e5dbfd2 100644 --- a/cutl/details/boost/regex/v4/perl_matcher_common.hpp +++ b/cutl/details/boost/regex/v4/perl_matcher_common.hpp @@ -65,6 +65,8 @@ void perl_matcher::construct_init(const basic_r m_match_flags |= match_perl; else if((re_f & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex)) m_match_flags |= match_perl; + else if((re_f & (regbase::main_option_type|regbase::literal)) == (regbase::literal)) + m_match_flags |= match_perl; else m_match_flags |= match_posix; } @@ -326,6 +328,10 @@ bool perl_matcher::match_prefix() m_has_found_match = true; m_presult->set_second(last, 0, false); position = last; + if((m_match_flags & match_posix) == match_posix) + { + m_result.maybe_assign(*m_presult); + } } #ifdef BOOST_REGEX_MATCH_EXTRA if(m_has_found_match && (match_extra & m_match_flags)) diff --git a/cutl/details/boost/regex/v4/perl_matcher_non_recursive.hpp b/cutl/details/boost/regex/v4/perl_matcher_non_recursive.hpp index e4b1e1e..9e3d74d 100644 --- a/cutl/details/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/cutl/details/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -828,9 +828,9 @@ bool perl_matcher::match_long_set_repeat() #ifdef __BORLANDC__ #pragma option push -w-8008 -w-8066 -w-8004 #endif - typedef typename traits::char_class_type mask_type; + typedef typename traits::char_class_type m_type; const re_repeat* rep = static_cast(pstate); - const re_set_long* set = static_cast*>(pstate->next.p); + const re_set_long* set = static_cast*>(pstate->next.p); std::size_t count = 0; // // start by working out how much we can skip: @@ -1268,6 +1268,9 @@ bool perl_matcher::unwind_fast_dot_repeat(bool }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip)); } + // remember where we got to if this is a leading repeat: + if((rep->leading) && (count < rep->max)) + restart = position; if(position == last) { // can't repeat any more, remove the pushed state: @@ -1434,7 +1437,7 @@ bool perl_matcher::unwind_short_set_repeat(bool template bool perl_matcher::unwind_long_set_repeat(bool r) { - typedef typename traits::char_class_type mask_type; + typedef typename traits::char_class_type m_type; saved_single_repeat* pmp = static_cast*>(m_backup_state); // if we have a match, just discard this state: @@ -1447,7 +1450,7 @@ bool perl_matcher::unwind_long_set_repeat(bool const re_repeat* rep = pmp->rep; std::size_t count = pmp->count; pstate = rep->next.p; - const re_set_long* set = static_cast*>(pstate); + const re_set_long* set = static_cast*>(pstate); position = pmp->last_position; BOOST_ASSERT(rep->type == syntax_element_long_set_rep); diff --git a/cutl/details/boost/regex/v4/regex_format.hpp b/cutl/details/boost/regex/v4/regex_format.hpp index 211859f..c4a60f9 100644 --- a/cutl/details/boost/regex/v4/regex_format.hpp +++ b/cutl/details/boost/regex/v4/regex_format.hpp @@ -180,8 +180,14 @@ private: } inline int toi(ForwardIter& i, ForwardIter j, int base) { +#if defined(_MSC_VER) && defined(__INTEL_COMPILER) && ((__INTEL_COMPILER == 9999) || (__INTEL_COMPILER == 1210)) + // Workaround for Intel support issue #656654. + // See also https://svn.boost.org/trac/boost/ticket/6359 + return toi(i, j, base, mpl::false_()); +#else typedef typename cutl_details_boost::is_convertible::type tag_type; return toi(i, j, base, tag_type()); +#endif } const traits& m_traits; // the traits class for localised formatting operations @@ -277,7 +283,8 @@ void basic_regex_formatter::format format_perl(); break; } - // fall through, not a special character: + // not a special character: + BOOST_FALLTHROUGH; default: put(*m_position); ++m_position; @@ -348,7 +355,7 @@ void basic_regex_formatter::format case '{': have_brace = true; ++m_position; - // fall through.... + BOOST_FALLTHROUGH; default: // see if we have a number: { @@ -842,7 +849,15 @@ OutputIterator regex_format_imp(OutputIterator out, BOOST_MPL_HAS_XXX_TRAIT_DEF(const_iterator) -struct any_type { any_type(...); }; +struct any_type +{ + template + any_type(const T&); + template + any_type(const T&, const U&); + template + any_type(const T&, const U&, const V&); +}; typedef char no_type; typedef char (&unary_type)[2]; typedef char (&binary_type)[3]; @@ -1050,7 +1065,7 @@ struct format_functor_c_string template OutputIter operator()(const Match& m, OutputIter i, cutl_details_boost::regex_constants::match_flag_type f, const Traits& t = Traits()) { - typedef typename Match::char_type char_type; + //typedef typename Match::char_type char_type; const charT* end = func; while(*end) ++end; return regex_format_imp(i, m, func, end, f, t); @@ -1069,7 +1084,7 @@ struct format_functor_container template OutputIter operator()(const Match& m, OutputIter i, cutl_details_boost::regex_constants::match_flag_type f, const Traits& t = Traits()) { - typedef typename Match::char_type char_type; + //typedef typename Match::char_type char_type; return re_detail::regex_format_imp(i, m, func.begin(), func.end(), f, t); } private: diff --git a/cutl/details/boost/regex/v4/regex_iterator.hpp b/cutl/details/boost/regex/v4/regex_iterator.hpp index daf8d22..82d0d09 100644 --- a/cutl/details/boost/regex/v4/regex_iterator.hpp +++ b/cutl/details/boost/regex/v4/regex_iterator.hpp @@ -68,7 +68,7 @@ public: // flags |= match_prev_avail; BidirectionalIterator next_start = what[0].second; match_flag_type f(flags); - if(!what.length()) + if(!what.length() || (f & regex_constants::match_posix)) f |= regex_constants::match_not_initial_null; //if(base != next_start) // f |= regex_constants::match_not_bob; diff --git a/cutl/details/boost/regex/v4/regex_split.hpp b/cutl/details/boost/regex/v4/regex_split.hpp index c90e0d4..db1bac0 100644 --- a/cutl/details/boost/regex/v4/regex_split.hpp +++ b/cutl/details/boost/regex/v4/regex_split.hpp @@ -107,7 +107,7 @@ std::size_t regex_split(OutputIterator out, std::size_t max_split) { typedef typename std::basic_string::const_iterator ci_t; - typedef typename match_results::allocator_type match_allocator; + //typedef typename match_results::allocator_type match_allocator; ci_t last = s.begin(); std::size_t init_size = max_split; re_detail::split_pred pred(&last, &out, &max_split); diff --git a/cutl/details/boost/regex/v4/regex_traits_defaults.hpp b/cutl/details/boost/regex/v4/regex_traits_defaults.hpp index 457d0ff..eeb0f2e 100644 --- a/cutl/details/boost/regex/v4/regex_traits_defaults.hpp +++ b/cutl/details/boost/regex/v4/regex_traits_defaults.hpp @@ -3,12 +3,12 @@ * Copyright (c) 2004 * John Maddock * - * Use, modification and distribution are subject to the - * Boost Software License, Version 1.0. (See accompanying file + * Use, modification and distribution are subject to the + * Boost Software License, Version 1.0. (See accompanying file * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * */ - + /* * LOCATION: see http://www.boost.org for most recent version. * FILE regex_traits_defaults.hpp @@ -85,7 +85,7 @@ inline bool is_combining(unsigned char) return false; } #if !defined(__hpux) && !defined(__WINSCW__) // can't use WCHAR_MAX/MIN in pp-directives -#ifdef _MSC_VER +#ifdef _MSC_VER template<> inline bool is_combining(wchar_t c) { @@ -115,11 +115,11 @@ template inline bool is_separator(charT c) { return BOOST_REGEX_MAKE_BOOL( - (c == static_cast('\n')) - || (c == static_cast('\r')) - || (c == static_cast('\f')) - || (static_cast(c) == 0x2028u) - || (static_cast(c) == 0x2029u) + (c == static_cast('\n')) + || (c == static_cast('\r')) + || (c == static_cast('\f')) + || (static_cast(c) == 0x2028u) + || (static_cast(c) == 0x2029u) || (static_cast(c) == 0x85u)); } template <> @@ -177,7 +177,7 @@ int get_default_class_id(const charT* p1, const charT* p2) 'x', 'd', 'i', 'g', 'i', 't', }; - static const character_pointer_range ranges[21] = + static const character_pointer_range ranges[21] = { {data+0, data+5,}, // alnum {data+5, data+10,}, // alpha @@ -203,7 +203,7 @@ int get_default_class_id(const charT* p1, const charT* p2) }; static const character_pointer_range* ranges_begin = ranges; static const character_pointer_range* ranges_end = ranges + (sizeof(ranges)/sizeof(ranges[0])); - + character_pointer_range t = { p1, p2, }; const character_pointer_range* p = std::lower_bound(ranges_begin, ranges_end, t); if((p != ranges_end) && (t == *p)) @@ -324,15 +324,15 @@ inline const charT* get_escape_R_string() # pragma warning(push) # pragma warning(disable:4309 4245) #endif - static const charT e1[] = { '(', '?', '>', '\x0D', '\x0A', '?', - '|', '[', '\x0A', '\x0B', '\x0C', '\x85', '\\', 'x', '{', '2', '0', '2', '8', '}', + static const charT e1[] = { '(', '?', '>', '\x0D', '\x0A', '?', + '|', '[', '\x0A', '\x0B', '\x0C', static_cast('\x85'), '\\', 'x', '{', '2', '0', '2', '8', '}', '\\', 'x', '{', '2', '0', '2', '9', '}', ']', ')', '\0' }; - static const charT e2[] = { '(', '?', '>', '\x0D', '\x0A', '?', - '|', '[', '\x0A', '\x0B', '\x0C', '\x85', ']', ')', '\0' }; + static const charT e2[] = { '(', '?', '>', '\x0D', '\x0A', '?', + '|', '[', '\x0A', '\x0B', '\x0C', static_cast('\x85'), ']', ')', '\0' }; charT c = static_cast(0x2029u); bool b = (static_cast(c) == 0x2029u); - + return (b ? e1 : e2); #ifdef BOOST_MSVC # pragma warning(pop) @@ -346,7 +346,7 @@ inline const char* get_escape_R_string() # pragma warning(push) # pragma warning(disable:4309) #endif - static const char e2[] = { '(', '?', '>', '\x0D', '\x0A', '?', + static const char e2[] = { '(', '?', '>', '\x0D', '\x0A', '?', '|', '[', '\x0A', '\x0B', '\x0C', '\x85', ']', ')', '\0' }; return e2; #ifdef BOOST_MSVC diff --git a/cutl/details/boost/regex/v4/u32regex_token_iterator.hpp b/cutl/details/boost/regex/v4/u32regex_token_iterator.hpp index 755f65e..0c7a533 100644 --- a/cutl/details/boost/regex/v4/u32regex_token_iterator.hpp +++ b/cutl/details/boost/regex/v4/u32regex_token_iterator.hpp @@ -317,14 +317,14 @@ inline u32regex_token_iterator make_u32regex_token_iterator(cons template inline u32regex_token_iterator make_u32regex_token_iterator(const UChar* p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) { - return u32regex_token_iterator(p, p+u_strlen(p), e, m); + return u32regex_token_iterator(p, p+u_strlen(p), e, submatch, m); } #endif template inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) { typedef typename std::basic_string::const_iterator iter_type; - return u32regex_token_iterator(p.begin(), p.end(), e, m); + return u32regex_token_iterator(p.begin(), p.end(), e, submatch, m); } template inline u32regex_token_iterator make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const int (&submatch)[N], regex_constants::match_flag_type m = regex_constants::match_default) @@ -354,7 +354,7 @@ template inline u32regex_token_iterator::const_iterator> make_u32regex_token_iterator(const std::basic_string& p, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) { typedef typename std::basic_string::const_iterator iter_type; - return u32regex_token_iterator(p.begin(), p.end(), e, m); + return u32regex_token_iterator(p.begin(), p.end(), e, submatch, m); } inline u32regex_token_iterator make_u32regex_token_iterator(const U_NAMESPACE_QUALIFIER UnicodeString& s, const u32regex& e, const std::vector& submatch, regex_constants::match_flag_type m = regex_constants::match_default) { -- cgit v1.1