mirror of
https://github.com/boostorg/regex.git
synced 2025-07-19 23:32:10 +02:00
Fixed nasty non-greedy repeat bug,
tidied up min/max workarounds, removed unneeded #if [SVN r22422]
This commit is contained in:
@ -21,7 +21,6 @@
|
|||||||
#define BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP
|
#define BOOST_REGEX_V4_PERL_MATCHER_NON_RECURSIVE_HPP
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <boost/minmax.hpp>
|
|
||||||
|
|
||||||
#ifdef BOOST_HAS_ABI_HEADERS
|
#ifdef BOOST_HAS_ABI_HEADERS
|
||||||
# include BOOST_ABI_PREFIX
|
# include BOOST_ABI_PREFIX
|
||||||
@ -547,7 +546,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_dot_repeat
|
|||||||
return match_dot_repeat_slow();
|
return match_dot_repeat_slow();
|
||||||
|
|
||||||
const re_repeat* rep = static_cast<const re_repeat*>(pstate);
|
const re_repeat* rep = static_cast<const re_repeat*>(pstate);
|
||||||
unsigned count = std_min(static_cast<unsigned>(re_detail::distance(position, last)), static_cast<unsigned>(rep->greedy ? rep->max : rep->min));
|
unsigned count = (std::min)(static_cast<unsigned>(re_detail::distance(position, last)), static_cast<unsigned>(rep->greedy ? rep->max : rep->min));
|
||||||
if(rep->min > count)
|
if(rep->min > count)
|
||||||
return false; // not enough text left to match
|
return false; // not enough text left to match
|
||||||
std::advance(position, count);
|
std::advance(position, count);
|
||||||
@ -594,7 +593,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_char_repea
|
|||||||
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
||||||
{
|
{
|
||||||
BidiIterator end = position;
|
BidiIterator end = position;
|
||||||
std::advance(end, std_min((unsigned)re_detail::distance(position, last), desired));
|
std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired));
|
||||||
BidiIterator origin(position);
|
BidiIterator origin(position);
|
||||||
while((position != end) && (traits_inst.translate(*position, icase) == what))
|
while((position != end) && (traits_inst.translate(*position, icase) == what))
|
||||||
{
|
{
|
||||||
@ -661,7 +660,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_set_repeat
|
|||||||
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
||||||
{
|
{
|
||||||
BidiIterator end = position;
|
BidiIterator end = position;
|
||||||
std::advance(end, std_min((unsigned)re_detail::distance(position, last), desired));
|
std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired));
|
||||||
BidiIterator origin(position);
|
BidiIterator origin(position);
|
||||||
while((position != end) && map[(traits_uchar_type)traits_inst.translate(*position, icase)])
|
while((position != end) && map[(traits_uchar_type)traits_inst.translate(*position, icase)])
|
||||||
{
|
{
|
||||||
@ -728,7 +727,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_long_set_r
|
|||||||
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
||||||
{
|
{
|
||||||
BidiIterator end = position;
|
BidiIterator end = position;
|
||||||
std::advance(end, std_min((unsigned)re_detail::distance(position, last), desired));
|
std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired));
|
||||||
BidiIterator origin(position);
|
BidiIterator origin(position);
|
||||||
while((position != end) && (position != re_is_set_member(position, last, set, re)))
|
while((position != end) && (position != re_is_set_member(position, last, set, re)))
|
||||||
{
|
{
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
#ifndef BOOST_REGEX_V4_PERL_MATCHER_RECURSIVE_HPP
|
#ifndef BOOST_REGEX_V4_PERL_MATCHER_RECURSIVE_HPP
|
||||||
#define BOOST_REGEX_V4_PERL_MATCHER_RECURSIVE_HPP
|
#define BOOST_REGEX_V4_PERL_MATCHER_RECURSIVE_HPP
|
||||||
|
|
||||||
#include <boost/minmax.hpp>
|
|
||||||
|
|
||||||
#ifdef BOOST_HAS_ABI_HEADERS
|
#ifdef BOOST_HAS_ABI_HEADERS
|
||||||
# include BOOST_ABI_PREFIX
|
# include BOOST_ABI_PREFIX
|
||||||
#endif
|
#endif
|
||||||
@ -402,7 +400,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_dot_repeat
|
|||||||
// start by working out how much we can skip:
|
// start by working out how much we can skip:
|
||||||
//
|
//
|
||||||
const re_repeat* rep = static_cast<const re_repeat*>(pstate);
|
const re_repeat* rep = static_cast<const re_repeat*>(pstate);
|
||||||
unsigned count = std_min(static_cast<unsigned>(re_detail::distance(position, last)), (rep->greedy ? rep->max : rep->min));
|
unsigned count = (std::min)(static_cast<unsigned>(re_detail::distance(position, last)), (rep->greedy ? rep->max : rep->min));
|
||||||
if(rep->min > count)
|
if(rep->min > count)
|
||||||
return false; // not enough text left to match
|
return false; // not enough text left to match
|
||||||
std::advance(position, count);
|
std::advance(position, count);
|
||||||
@ -460,7 +458,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_char_repea
|
|||||||
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
||||||
{
|
{
|
||||||
BidiIterator end = position;
|
BidiIterator end = position;
|
||||||
std::advance(end, std_min((unsigned)re_detail::distance(position, last), desired));
|
std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired));
|
||||||
BidiIterator origin(position);
|
BidiIterator origin(position);
|
||||||
while((position != end) && (traits_inst.translate(*position, icase) == what))
|
while((position != end) && (traits_inst.translate(*position, icase) == what))
|
||||||
{
|
{
|
||||||
@ -509,8 +507,16 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_char_repea
|
|||||||
return false;
|
return false;
|
||||||
if(position == last)
|
if(position == last)
|
||||||
return false;
|
return false;
|
||||||
position = ++save_pos;
|
position = save_pos;
|
||||||
++count;
|
if(traits_inst.translate(*position, icase) == what)
|
||||||
|
{
|
||||||
|
++position;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}while(true);
|
}while(true);
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma option pop
|
#pragma option pop
|
||||||
@ -540,7 +546,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_set_repeat
|
|||||||
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
||||||
{
|
{
|
||||||
BidiIterator end = position;
|
BidiIterator end = position;
|
||||||
std::advance(end, std_min((unsigned)re_detail::distance(position, last), desired));
|
std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired));
|
||||||
BidiIterator origin(position);
|
BidiIterator origin(position);
|
||||||
while((position != end) && map[(traits_uchar_type)traits_inst.translate(*position, icase)])
|
while((position != end) && map[(traits_uchar_type)traits_inst.translate(*position, icase)])
|
||||||
{
|
{
|
||||||
@ -589,8 +595,16 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_set_repeat
|
|||||||
return false;
|
return false;
|
||||||
if(position == last)
|
if(position == last)
|
||||||
return false;
|
return false;
|
||||||
position = ++save_pos;
|
position = save_pos;
|
||||||
++count;
|
if(map[(traits_uchar_type)traits_inst.translate(*position, icase)])
|
||||||
|
{
|
||||||
|
++position;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}while(true);
|
}while(true);
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma option pop
|
#pragma option pop
|
||||||
@ -620,7 +634,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_long_set_r
|
|||||||
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
if(::boost::is_random_access_iterator<BidiIterator>::value)
|
||||||
{
|
{
|
||||||
BidiIterator end = position;
|
BidiIterator end = position;
|
||||||
std::advance(end, std_min((unsigned)re_detail::distance(position, last), desired));
|
std::advance(end, (std::min)((unsigned)re_detail::distance(position, last), desired));
|
||||||
BidiIterator origin(position);
|
BidiIterator origin(position);
|
||||||
while((position != end) && (position != re_is_set_member(position, last, set, re)))
|
while((position != end) && (position != re_is_set_member(position, last, set, re)))
|
||||||
{
|
{
|
||||||
@ -669,8 +683,16 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_long_set_r
|
|||||||
return false;
|
return false;
|
||||||
if(position == last)
|
if(position == last)
|
||||||
return false;
|
return false;
|
||||||
position = ++save_pos;
|
position = save_pos;
|
||||||
++count;
|
if(position != re_is_set_member(position, last, set, re))
|
||||||
|
{
|
||||||
|
++position;
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}while(true);
|
}while(true);
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma option pop
|
#pragma option pop
|
||||||
|
@ -51,11 +51,7 @@ template <class BidirectionalIterator,
|
|||||||
class regex_token_iterator_implementation
|
class regex_token_iterator_implementation
|
||||||
{
|
{
|
||||||
typedef basic_regex<charT, traits, Allocator> regex_type;
|
typedef basic_regex<charT, traits, Allocator> regex_type;
|
||||||
#if 1
|
|
||||||
typedef sub_match<BidirectionalIterator> value_type;
|
typedef sub_match<BidirectionalIterator> value_type;
|
||||||
#else
|
|
||||||
typedef std::basic_string<charT> value_type;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
match_results<BidirectionalIterator> what; // current match
|
match_results<BidirectionalIterator> what; // current match
|
||||||
BidirectionalIterator end; // end of search area
|
BidirectionalIterator end; // end of search area
|
||||||
|
Reference in New Issue
Block a user