diff --git a/include/boost/regex/v3/regex_compile.hpp b/include/boost/regex/v3/regex_compile.hpp index 3f558dbc..b1b7e972 100644 --- a/include/boost/regex/v3/regex_compile.hpp +++ b/include/boost/regex/v3/regex_compile.hpp @@ -195,7 +195,9 @@ unsigned int BOOST_REGEX_CALL reg_expression::parse_in unsigned int result = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+1)); if((result == traits_type::syntax_colon) && ((first-base) == 5)) { - return traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+2)); + unsigned type = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+2)); + if((type == traits_type::syntax_left_word) || (type == traits_type::syntax_right_word)) + return type; } return ((result == traits_type::syntax_colon) || (result == traits_type::syntax_dot) || (result == traits_type::syntax_equal)) ? result : 0; } diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp index ddd98283..29e1f647 100644 --- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -90,7 +90,7 @@ struct save_state_init *base = static_cast(get_mem_block()); *end = reinterpret_cast(reinterpret_cast(*base)+BOOST_REGEX_BLOCKSIZE); --(*end); - new (*end)saved_state(0); + (void) new (*end)saved_state(0); assert(*end > *base); } ~save_state_init() @@ -175,7 +175,7 @@ void perl_matcher::extend_stack() backup_state = reinterpret_cast(reinterpret_cast(stack_base)+BOOST_REGEX_BLOCKSIZE); saved_extra_block* block = static_cast(backup_state); --block; - new (block) saved_extra_block(m_stack_base, m_backup_state); + (void) new (block) saved_extra_block(m_stack_base, m_backup_state); m_stack_base = stack_base; m_backup_state = block; } @@ -195,7 +195,7 @@ inline void perl_matcher::push_matc pmp = static_cast*>(m_backup_state); --pmp; } - new (pmp)saved_matched_paren(index, sub); + (void) new (pmp)saved_matched_paren(index, sub); m_backup_state = pmp; } @@ -210,7 +210,7 @@ inline void perl_matcher::push_recu pmp = m_backup_state; --pmp; } - new (pmp)saved_state(saved_type_recurse); + (void) new (pmp)saved_state(saved_type_recurse); m_backup_state = pmp; } @@ -225,7 +225,7 @@ inline void perl_matcher::push_asse pmp = static_cast*>(m_backup_state); --pmp; } - new (pmp)saved_assertion(positive, ps, position); + (void) new (pmp)saved_assertion(positive, ps, position); m_backup_state = pmp; } @@ -240,7 +240,7 @@ inline void perl_matcher::push_alt( pmp = static_cast*>(m_backup_state); --pmp; } - new (pmp)saved_position(ps, position, saved_state_alt); + (void) new (pmp)saved_position(ps, position, saved_state_alt); m_backup_state = pmp; } @@ -255,7 +255,7 @@ inline void perl_matcher::push_non_ pmp = static_cast*>(m_backup_state); --pmp; } - new (pmp)saved_position(ps, position, saved_state_non_greedy_long_repeat); + (void) new (pmp)saved_position(ps, position, saved_state_non_greedy_long_repeat); m_backup_state = pmp; } @@ -270,7 +270,7 @@ inline void perl_matcher::push_repe pmp = static_cast*>(m_backup_state); --pmp; } - new (pmp)saved_repeater(i, s, position); + (void) new (pmp)saved_repeater(i, s, position); m_backup_state = pmp; } @@ -285,7 +285,7 @@ inline void perl_matcher::push_sing pmp = static_cast*>(m_backup_state); --pmp; } - new (pmp)saved_single_repeat(c, r, last_position, id); + (void) new (pmp)saved_single_repeat(c, r, last_position, id); m_backup_state = pmp; } diff --git a/include/boost/regex/v4/regex_compile.hpp b/include/boost/regex/v4/regex_compile.hpp index 9f0bd758..e1579a90 100644 --- a/include/boost/regex/v4/regex_compile.hpp +++ b/include/boost/regex/v4/regex_compile.hpp @@ -66,11 +66,25 @@ bool BOOST_REGEX_CALL re_maybe_set_member(charT c, } // namespace re_detail +template +struct is_big_char +{ + typedef typename traits::uchar_type traits_uchar_type; + typedef typename traits::size_type traits_size_type; + static bool test(char) + { return false; } + static bool test(unsigned char) + { return false; } + static bool test(signed char) + { return false; } + template static bool test(charT c) + { return (traits_size_type)(traits_uchar_type)c >= 256; } +}; template inline bool BOOST_REGEX_CALL reg_expression::can_start(charT c, const unsigned char* _map, unsigned char mask, const re_detail::_wide_type&) { - if((traits_size_type)(traits_uchar_type)c >= 256) + if(is_big_char::test(c)) return true; return BOOST_REGEX_MAKE_BOOL(_map[(traits_uchar_type)c] & mask); } @@ -209,7 +223,9 @@ unsigned int BOOST_REGEX_CALL reg_expression::parse_in unsigned int result = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+1)); if((result == traits_type::syntax_colon) && ((first-base) == 5)) { - return traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+2)); + unsigned type = traits_inst.syntax_type((traits_size_type)(traits_uchar_type)*(base+2)); + if((type == traits_type::syntax_left_word) || (type == traits_type::syntax_right_word)) + return type; } return ((result == traits_type::syntax_colon) || (result == traits_type::syntax_dot) || (result == traits_type::syntax_equal)) ? result : 0; } diff --git a/include/boost/regex/v4/regex_traits.hpp b/include/boost/regex/v4/regex_traits.hpp index 6859b38c..7ae29966 100644 --- a/include/boost/regex/v4/regex_traits.hpp +++ b/include/boost/regex/v4/regex_traits.hpp @@ -562,7 +562,7 @@ struct BOOST_REGEX_DECL cpp_regex_traits_base : public regex_traits_base char_class_digit = std::ctype_base::digit, char_class_graph = std::ctype_base::graph, char_class_lower = std::ctype_base::lower, - char_class_print = std::ctype_base::print, + char_class_print = 0,//std::ctype_base::print, char_class_punct = std::ctype_base::punct, char_class_space = std::ctype_base::space, char_class_upper = std::ctype_base::upper, diff --git a/include/boost/regex/v4/sub_match.hpp b/include/boost/regex/v4/sub_match.hpp index 7e6712ac..194769ed 100644 --- a/include/boost/regex/v4/sub_match.hpp +++ b/include/boost/regex/v4/sub_match.hpp @@ -271,6 +271,7 @@ operator + (const sub_match& m, result.reserve(s.size() + m.length() + 1); return result.append(m.first, m.second).append(s); } +#if !(defined(__GNUC__) && defined(BOOST_NO_STD_LOCALE)) template inline std::basic_string::value_type> operator + (typename re_detail::regex_iterator_traits::value_type const* s, @@ -289,6 +290,23 @@ operator + (const sub_match& m, result.reserve(std::char_traits::value_type>::length(s) + m.length() + 1); return result.append(m.first, m.second).append(s); } +#else +// worwaround versions: +template +inline std::basic_string::value_type> +operator + (typename re_detail::regex_iterator_traits::value_type const* s, + const sub_match& m) +{ + return s + m.str(); +} +template +inline std::basic_string::value_type> +operator + (const sub_match& m, + typename re_detail::regex_iterator_traits::value_type const * s) +{ + return m.str() + s; +} +#endif template inline std::basic_string::value_type> operator + (typename re_detail::regex_iterator_traits::value_type const& s, diff --git a/src/cpp_regex_traits.cpp b/src/cpp_regex_traits.cpp index db9d39bb..3aaca1cf 100644 --- a/src/cpp_regex_traits.cpp +++ b/src/cpp_regex_traits.cpp @@ -155,11 +155,11 @@ parser_buf::seekpos(pos_type sp, ::std::ios_base::openmode which) { if(which & ::std::ios_base::out) return pos_type(off_type(-1)); - std::ptrdiff_t size = this->egptr() - this->eback(); + off_type size = this->egptr() - this->eback(); charT* g = this->eback(); - if(sp <= size) + if(off_type(sp) <= size) { - this->setg(g, g + ::std::streamsize(sp), g + size); + this->setg(g, g + off_type(sp), g + size); } return pos_type(off_type(-1)); } @@ -234,7 +234,7 @@ message_data::message_data(const std::locale& l, std::string regex_message #endif for(std::size_t j = 0; j < s.size(); ++j) { - syntax_map[s[j]] = (unsigned char)(i); + syntax_map[(unsigned char)s[j]] = (unsigned char)(i); } } @@ -640,7 +640,11 @@ message_data::message_data(const std::locale& l, const std::string& reg #endif for(unsigned int j = 0; j < s.size(); ++j) { +#if defined(WCHAR_MIN) && (WCHAR_MIN == 0) + if(s[j] <= UCHAR_MAX) +#else if((s[j] <= UCHAR_MAX) && (s[j] >= 0)) +#endif syntax_[s[j]] = static_cast(i); else { diff --git a/src/regex.cpp b/src/regex.cpp index e6f16307..da0ed369 100644 --- a/src/regex.cpp +++ b/src/regex.cpp @@ -123,7 +123,7 @@ BOOST_REGEX_DECL void BOOST_REGEX_CALL put_mem_block(void* p) #else -mem_block_cache block_cache = { 0, }; +mem_block_cache block_cache = { 0, 0, }; BOOST_REGEX_DECL void* BOOST_REGEX_CALL get_mem_block() { diff --git a/test/concepts/concept_check.cpp b/test/concepts/concept_check.cpp index bbe66b13..bf936bc2 100644 --- a/test/concepts/concept_check.cpp +++ b/test/concepts/concept_check.cpp @@ -28,7 +28,7 @@ int main() typedef boost::bidirectional_iterator_archetype iterator_type; typedef boost::input_iterator_archetype input_iterator_type; input_iterator_type i, j; -#if!defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) +#if!defined(BOOST_NO_MEMBER_TEMPLATES) && !defined(__IBMCPP__) && !BOOST_WORKAROUND(__GNUC__, < 3) boost::regex r(i, j); r.assign(i, j); #else @@ -62,7 +62,6 @@ int main() boost::regex_token_iterator > >(); -#endif #endif // // verify basic_regex member functions: @@ -81,7 +80,7 @@ int main() r.assign(s, boost::regex::perl); r.assign(c_exp, c_exp+1); r.assign(c_exp, c_exp+1, boost::regex::perl); - +#endif return 0; }