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]
This commit is contained in:
John Maddock
2002-06-08 10:36:54 +00:00
parent b856079e74
commit b2c4abc9cf

View File

@ -351,6 +351,8 @@ bool query_match_aux(iterator first,
// longer one. // longer one.
if((flags & match_not_null) && (first == temp_match[0].first)) if((flags & match_not_null) && (first == temp_match[0].first))
goto failure; goto failure;
if((flags & match_all) && (first != last))
goto failure;
temp_match.set_second(first); temp_match.set_second(first);
m.maybe_assign(temp_match); m.maybe_assign(temp_match);
match_found = true; match_found = true;
@ -1653,9 +1655,7 @@ bool regex_match(iterator first, iterator last, match_results<iterator, Allocato
re_detail::_priv_match_data<iterator, Allocator> pd(m); re_detail::_priv_match_data<iterator, Allocator> pd(m);
iterator restart; iterator restart;
bool result = re_detail::query_match_aux(first, last, m, e, flags, pd, &restart); bool result = re_detail::query_match_aux(first, last, m, e, flags, pd, &restart);
if(result && (last == m[0].second)) return result;
return true;
return false;
} }
template <class iterator, class charT, class traits, class Allocator2> template <class iterator, class charT, class traits, class Allocator2>
bool regex_match(iterator first, iterator last, const reg_expression<charT, traits, Allocator2>& e, unsigned flags = match_default) bool regex_match(iterator first, iterator last, const reg_expression<charT, traits, Allocator2>& e, unsigned flags = match_default)