mirror of
https://github.com/boostorg/regex.git
synced 2025-07-17 22:32:09 +02:00
Added patches from 1.33 branch:
Fix trailing - in ranges so that [a-b-] works. Fix performance issue: don't call std::distance on bidirectional iterators. [SVN r31533]
This commit is contained in:
@ -1220,6 +1220,17 @@ void basic_regex_parser<charT, traits>::parse_set_literal(basic_char_set<charT,
|
|||||||
char_set.add_range(start_range, end_range);
|
char_set.add_range(start_range, end_range);
|
||||||
if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_dash)
|
if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_dash)
|
||||||
{
|
{
|
||||||
|
if(m_end == ++m_position)
|
||||||
|
{
|
||||||
|
fail(regex_constants::error_brack, m_position - m_base);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_close_set)
|
||||||
|
{
|
||||||
|
// trailing - :
|
||||||
|
--m_position;
|
||||||
|
return;
|
||||||
|
}
|
||||||
fail(regex_constants::error_range, m_position - m_base);
|
fail(regex_constants::error_range, m_position - m_base);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -658,12 +658,32 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_restart_continue()
|
|||||||
template <class BidiIterator, class Allocator, class traits>
|
template <class BidiIterator, class Allocator, class traits>
|
||||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_backstep()
|
bool perl_matcher<BidiIterator, Allocator, traits>::match_backstep()
|
||||||
{
|
{
|
||||||
std::ptrdiff_t maxlen = ::boost::re_detail::distance(backstop, position);
|
#ifdef BOOST_MSVC
|
||||||
if(maxlen < static_cast<const re_brace*>(pstate)->index)
|
#pragma warning(push)
|
||||||
return false;
|
#pragma warning(disable:4127)
|
||||||
std::advance(position, -static_cast<const re_brace*>(pstate)->index);
|
#endif
|
||||||
|
if( ::boost::is_random_access_iterator<BidiIterator>::value)
|
||||||
|
{
|
||||||
|
std::ptrdiff_t maxlen = ::boost::re_detail::distance(backstop, position);
|
||||||
|
if(maxlen < static_cast<const re_brace*>(pstate)->index)
|
||||||
|
return false;
|
||||||
|
std::advance(position, -static_cast<const re_brace*>(pstate)->index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int c = static_cast<const re_brace*>(pstate)->index;
|
||||||
|
while(c--)
|
||||||
|
{
|
||||||
|
if(position == backstop)
|
||||||
|
return false;
|
||||||
|
--position;
|
||||||
|
}
|
||||||
|
}
|
||||||
pstate = pstate->next.p;
|
pstate = pstate->next.p;
|
||||||
return true;
|
return true;
|
||||||
|
#ifdef BOOST_MSVC
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class BidiIterator, class Allocator, class traits>
|
template <class BidiIterator, class Allocator, class traits>
|
||||||
|
Reference in New Issue
Block a user