diff --git a/include/boost/regex/v4/basic_regex_creator.hpp b/include/boost/regex/v4/basic_regex_creator.hpp index 623c83f0..3e7b79a0 100644 --- a/include/boost/regex/v4/basic_regex_creator.hpp +++ b/include/boost/regex/v4/basic_regex_creator.hpp @@ -572,9 +572,10 @@ re_syntax_base* basic_regex_creator::append_set( // Oops error: return 0; } + BOOST_ASSERT(c3[1] == 0); for(unsigned i = 0; i < (1u << CHAR_BIT); ++i) { - charT c3[2] = { static_cast(i), charT(0), }; + c3[0] = static_cast(i); string_type s3 = this->m_traits.transform(c3, c3 +1); if((s1 <= s3) && (s3 <= s2)) result->_map[i] = true; @@ -796,6 +797,7 @@ void basic_regex_creator::create_startmaps(re_syntax_base* state) v.pop_back(); // Build maps: + 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; create_startmap(static_cast(state)->alt.p, static_cast(state)->_map, &static_cast(state)->can_be_null, mask_skip); @@ -1181,7 +1183,8 @@ bool basic_regex_creator::is_bad_repeat(re_syntax_base* pt) unsigned id = static_cast(pt)->id; if(id > sizeof(m_bad_repeats) * CHAR_BIT) return true; // run out of bits, assume we can't traverse this one. - return m_bad_repeats & static_cast(1uL << id); + static const boost::uintmax_t one = 1uL; + return m_bad_repeats & (one << id); } default: return false; @@ -1200,8 +1203,9 @@ void basic_regex_creator::set_bad_repeat(re_syntax_base* pt) case syntax_element_long_set_rep: { unsigned id = static_cast(pt)->id; + static const boost::uintmax_t one = 1uL; if(id <= sizeof(m_bad_repeats) * CHAR_BIT) - m_bad_repeats |= static_cast(1uL << id); + m_bad_repeats |= (one << id); } default: break; diff --git a/include/boost/regex/v4/perl_matcher_recursive.hpp b/include/boost/regex/v4/perl_matcher_recursive.hpp index a93758c0..691f2a6f 100644 --- a/include/boost/regex/v4/perl_matcher_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_recursive.hpp @@ -614,7 +614,7 @@ bool perl_matcher::match_set_repeat() if(::boost::is_random_access_iterator::value) { BidiIterator end = position; - std::advance(end, (std::min)((unsigned)::boost::re_detail::distance(position, last), desired)); + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); BidiIterator origin(position); while((position != end) && map[static_cast(traits_inst.translate(*position, icase))]) { @@ -704,7 +704,7 @@ bool perl_matcher::match_long_set_repeat() if(::boost::is_random_access_iterator::value) { BidiIterator end = position; - std::advance(end, (std::min)((unsigned)::boost::re_detail::distance(position, last), desired)); + std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); BidiIterator origin(position); while((position != end) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) { diff --git a/include/boost/regex/v4/regex_traits_defaults.hpp b/include/boost/regex/v4/regex_traits_defaults.hpp index 095c2b35..44b9aed8 100644 --- a/include/boost/regex/v4/regex_traits_defaults.hpp +++ b/include/boost/regex/v4/regex_traits_defaults.hpp @@ -142,7 +142,11 @@ struct character_pointer_range } bool operator == (const character_pointer_range& r)const { - return ((p2 - p1) == (r.p2 - r.p1)) && std::equal(p1, p2, r.p1); + // Not only do we check that the ranges are of equal size before + // calling std::equal, but there is no other algorithm available: + // not even a non-standard MS one. So forward to unchecked_equal + // in the MS case. + return ((p2 - p1) == (r.p2 - r.p1)) && re_detail::equal(p1, p2, r.p1); } }; template diff --git a/include/boost/regex/v4/regex_workaround.hpp b/include/boost/regex/v4/regex_workaround.hpp index 695e8f65..3659c072 100644 --- a/include/boost/regex/v4/regex_workaround.hpp +++ b/include/boost/regex/v4/regex_workaround.hpp @@ -128,7 +128,7 @@ inline void pointer_construct(T* p, const T& t) #ifdef __cplusplus namespace boost{ namespace re_detail{ -#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) +#if BOOST_WORKAROUND(BOOST_MSVC,>=1400) && defined(_CPPLIB_VER) && !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) // // MSVC 8 will either emit warnings or else refuse to compile // code that makes perfectly legitimate use of std::copy, when @@ -144,12 +144,22 @@ namespace boost{ namespace re_detail{ { return stdext::unchecked_copy(first, last, dest); } + template + inline bool equal( + InputIterator1 first, + InputIterator1 last, + InputIterator2 with + ) + { + return stdext::unchecked_equal(first, last, with); + } // use safe versions of strcpy etc: using ::strcpy_s; using ::strcat_s; #else using std::copy; + using std::equal; inline std::size_t strcpy_s( char *strDestination,