diff --git a/include/boost/re_detail/regex_compile.hpp b/include/boost/re_detail/regex_compile.hpp index 3906f6dc..a71c5743 100644 --- a/include/boost/re_detail/regex_compile.hpp +++ b/include/boost/re_detail/regex_compile.hpp @@ -103,21 +103,21 @@ template CONSTRUCTOR_INLINE reg_expression::reg_expression(const charT* p, flag_type f, const Allocator& a) : data(a), pkmp(0), error_code_(REG_EMPTY) { - set_expression(p, f); + set_expression(p, f | regbase::use_except); } template CONSTRUCTOR_INLINE reg_expression::reg_expression(const charT* p1, const charT* p2, flag_type f, const Allocator& a) : data(a), pkmp(0), error_code_(REG_EMPTY) { - set_expression(p1, p2, f); + set_expression(p1, p2, f | regbase::use_except); } template CONSTRUCTOR_INLINE reg_expression::reg_expression(const charT* p, size_type len, flag_type f, const Allocator& a) : data(a), pkmp(0), error_code_(REG_EMPTY) { - set_expression(p, p + len, f); + set_expression(p, p + len, f | regbase::use_except); } template @@ -130,10 +130,13 @@ reg_expression::reg_expression(const reg_expression @@ -153,7 +156,7 @@ reg_expression& BOOST_RE_CALL reg_expression::fail(unsigned int e { error_code_ = err; if(err) - throw bad_expression(traits_inst.error_string(err)); + { + _flags |= regbase::failbit; + if(_flags & regbase::use_except) + { + throw bad_expression(traits_inst.error_string(err)); + } + } + else + _flags &= ~regbase::failbit; } diff --git a/include/boost/re_detail/regex_match.hpp b/include/boost/re_detail/regex_match.hpp index 7c7535fc..45f07b91 100644 --- a/include/boost/re_detail/regex_match.hpp +++ b/include/boost/re_detail/regex_match.hpp @@ -879,6 +879,7 @@ bool query_match_aux(iterator first, && (first == last)) // end of input has been reached { have_partial_match = true; + temp_match.set_second(first, 0, false); m.maybe_assign(temp_match); } diff --git a/include/boost/regex.hpp b/include/boost/regex.hpp index 0f258507..f3765087 100644 --- a/include/boost/regex.hpp +++ b/include/boost/regex.hpp @@ -521,7 +521,7 @@ public: template explicit reg_expression(const std::basic_string& p, flag_type f = regbase::normal, const Allocator& a = Allocator()) - : data(a), pkmp(0) { set_expression(p, f); } + : data(a), pkmp(0) { set_expression(p, f | regbase::use_except); } template reg_expression(I first, I last, flag_type f = regbase::normal, const Allocator& al = Allocator()) @@ -562,10 +562,10 @@ public: } #elif !defined(BOOST_RE_NO_STRING_DEF_ARGS) unsigned int BOOST_RE_CALL set_expression(const std::basic_string& p, flag_type f = regbase::normal) - { return set_expression(p.data(), p.data() + p.size(), f); } + { return set_expression(p.data(), p.data() + p.size(), f | regbase::use_except); } reg_expression(const std::basic_string& p, flag_type f = regbase::normal, const Allocator& a = Allocator()) - : data(a), pkmp(0) { set_expression(p, f); } + : data(a), pkmp(0) { set_expression(p, f | regbase::use_except); } reg_expression& BOOST_RE_CALL operator=(const std::basic_string& p) { @@ -980,11 +980,11 @@ public: ref->tail.matched = (ref->tail.first == ref->tail.second) ? false : true; } - void BOOST_RE_CALL set_second(iterator i, size_t pos) + void BOOST_RE_CALL set_second(iterator i, size_t pos, bool m = true) { cow(); ((sub_match*)((char*)ref + sizeof(c_reference) + sizeof(sub_match) * pos))->second = i; - ((sub_match*)((char*)ref + sizeof(c_reference) + sizeof(sub_match) * pos))->matched = true; + ((sub_match*)((char*)ref + sizeof(c_reference) + sizeof(sub_match) * pos))->matched = m; if(pos == 0) { ref->tail.first = i;