diff --git a/include/boost/regex/config.hpp b/include/boost/regex/config.hpp index fa102783..107824d8 100644 --- a/include/boost/regex/config.hpp +++ b/include/boost/regex/config.hpp @@ -125,8 +125,10 @@ // If there isn't good enough wide character support then there will // be no wide character regular expressions: // -#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) && !defined(BOOST_NO_WREGEX) -# define BOOST_NO_WREGEX +#if (defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)) +# if !defined(BOOST_NO_WREGEX) +# define BOOST_NO_WREGEX +# endif #else # if defined(__sgi) && defined(__SGI_STL_PORT) // STLPort on IRIX is misconfigured: does not compile @@ -645,3 +647,4 @@ inline void pointer_construct(T* p, const T& t) + diff --git a/include/boost/regex/v3/regex_compile.hpp b/include/boost/regex/v3/regex_compile.hpp index 505353af..5059b5f9 100644 --- a/include/boost/regex/v3/regex_compile.hpp +++ b/include/boost/regex/v3/regex_compile.hpp @@ -1990,6 +1990,8 @@ unsigned int BOOST_REGEX_CALL reg_expression::probe_re { case re_detail::syntax_element_startmark: case re_detail::syntax_element_endmark: + if(static_cast(dat)->index == -2) + return regbase::restart_any; return probe_restart(dat->next.p); case re_detail::syntax_element_start_line: return regbase::restart_line; @@ -2018,7 +2020,7 @@ unsigned int BOOST_REGEX_CALL reg_expression::fixup_le if((leading_lit) && (static_cast(dat)->length > 2)) { // we can do a literal search for the leading literal string - // using Knuth-Morris-Pratt (or whatever), and only then check for + // using Knuth-Morris-Pratt (or whatever), and only then check for // matches. We need a decent length string though to make it // worth while. _leading_string = reinterpret_cast(reinterpret_cast(dat) + sizeof(re_detail::re_literal)); @@ -2070,6 +2072,10 @@ unsigned int BOOST_REGEX_CALL reg_expression::fixup_le return len; } return len; + case re_detail::syntax_element_startmark: + if(static_cast(dat)->index == -2) + return 0; + // fall through: default: break; } diff --git a/include/boost/regex/v3/regex_match.hpp b/include/boost/regex/v3/regex_match.hpp index 7576240e..ad5362c4 100644 --- a/include/boost/regex/v3/regex_match.hpp +++ b/include/boost/regex/v3/regex_match.hpp @@ -56,8 +56,10 @@ inline int string_compare(const std::basic_string& s, const C* p) { return s.compare(p); } inline int string_compare(const std::string& s, const char* p) { return std::strcmp(s.c_str(), p); } +# ifndef BOOST_NO_WREGEX inline int string_compare(const std::wstring& s, const wchar_t* p) { return std::wcscmp(s.c_str(), p); } +# endif # define STR_COMP(s,p) string_compare(s,p) #endif @@ -753,6 +755,15 @@ bool query_match_aux(iterator first, start_loop[cur_acc] = first; continue; } + else if((unsigned int)accumulators[cur_acc] < static_cast(ptr)->min) + { + // the repeat was null, and we haven't gone round min times yet, + // since all subsequent repeats will be null as well, just update + // our repeat count and skip out. + accumulators[cur_acc] = static_cast(ptr)->min; + ptr = static_cast(ptr)->alt.p; + continue; + } goto failure; } // see if we can skip the repeat: @@ -809,6 +820,15 @@ bool query_match_aux(iterator first, start_loop[cur_acc] = first; continue; } + else if((first == start_loop[cur_acc]) && accumulators[cur_acc] && ((unsigned int)accumulators[cur_acc] < static_cast(ptr)->min)) + { + // the repeat was null, and we haven't gone round min times yet, + // since all subsequent repeats will be null as well, just update + // our repeat count and skip out. + accumulators[cur_acc] = static_cast(ptr)->min; + ptr = static_cast(ptr)->alt.p; + continue; + } // if we get here then neither option is allowed so fail: goto failure; @@ -826,7 +846,7 @@ bool query_match_aux(iterator first, if(flags & match_not_eob) goto failure; iterator p(first); - while((p != last) && traits_inst.is_separator(traits_inst.translate(*first, icase)))++p; + while((p != last) && traits_inst.is_separator(traits_inst.translate(*p, icase)))++p; if(p != last) goto failure; ptr = ptr->next.p; @@ -958,6 +978,12 @@ bool query_match_aux(iterator first, goto failure; ptr = ptr->next.p; continue; + case syntax_element_backref: + if(temp_match[static_cast(ptr)->index].first + != temp_match[static_cast(ptr)->index].second) + goto failure; + ptr = ptr->next.p; + continue; default: goto failure; }