From b2c4abc9cf6cc57103b23e4a136da0eacaa2779b Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 8 Jun 2002 10:36:54 +0000 Subject: [PATCH] Fixed partial match bug: The following program demonstrates what we believe is a bug in regex partial match algorithm: int main() { // boost::regex const re("(ab)?c"); // ok boost::regex const re("(ab)?"); // fails in the assert below boost::cmatch what; assert(boost::regex_match( "a", what, re, boost::match_default | boost::match_partial )); } [SVN r14110] --- include/boost/regex/detail/regex_match.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/regex/detail/regex_match.hpp b/include/boost/regex/detail/regex_match.hpp index 7c95b589..da97ecce 100644 --- a/include/boost/regex/detail/regex_match.hpp +++ b/include/boost/regex/detail/regex_match.hpp @@ -351,6 +351,8 @@ bool query_match_aux(iterator first, // longer one. if((flags & match_not_null) && (first == temp_match[0].first)) goto failure; + if((flags & match_all) && (first != last)) + goto failure; temp_match.set_second(first); m.maybe_assign(temp_match); match_found = true; @@ -1653,9 +1655,7 @@ bool regex_match(iterator first, iterator last, match_results pd(m); iterator restart; bool result = re_detail::query_match_aux(first, last, m, e, flags, pd, &restart); - if(result && (last == m[0].second)) - return true; - return false; + return result; } template bool regex_match(iterator first, iterator last, const reg_expression& e, unsigned flags = match_default)