mirror of
https://github.com/boostorg/regex.git
synced 2025-07-17 22:32:09 +02:00
merged changes in regex5 branch
[SVN r26692]
This commit is contained in:
@ -31,14 +31,14 @@
|
||||
namespace boost{
|
||||
namespace re_detail{
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
perl_matcher<BidiIterator, Allocator, traits, Allocator2>::perl_matcher(BidiIterator first, BidiIterator end,
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
perl_matcher<BidiIterator, Allocator, traits>::perl_matcher(BidiIterator first, BidiIterator end,
|
||||
match_results<BidiIterator, Allocator>& what,
|
||||
const reg_expression<char_type, traits, Allocator2>& e,
|
||||
const basic_regex<char_type, traits>& e,
|
||||
match_flag_type f)
|
||||
: m_result(what), base(first), last(end),
|
||||
position(first), re(e), traits_inst(e.get_traits()),
|
||||
next_count(&rep_obj), rep_obj(&next_count)
|
||||
m_independent(false), next_count(&rep_obj), rep_obj(&next_count)
|
||||
{
|
||||
typedef typename regex_iterator_traits<BidiIterator>::iterator_category category;
|
||||
|
||||
@ -54,7 +54,9 @@ perl_matcher<BidiIterator, Allocator, traits, Allocator2>::perl_matcher(BidiIter
|
||||
estimate_max_state_count(static_cast<category*>(0));
|
||||
if(!(m_match_flags & (match_perl|match_posix)))
|
||||
{
|
||||
if((re.flags() & regex_constants::perlex) || (re.flags() & regex_constants::literal))
|
||||
if((re.flags() & (regbase::main_option_type|regbase::no_perl_ex)) == 0)
|
||||
m_match_flags |= match_perl;
|
||||
else if((re.flags() & (regbase::main_option_type|regbase::emacs_ex)) == (regbase::basic_syntax_group|regbase::emacs_ex))
|
||||
m_match_flags |= match_perl;
|
||||
else
|
||||
m_match_flags |= match_posix;
|
||||
@ -70,32 +72,40 @@ perl_matcher<BidiIterator, Allocator, traits, Allocator2>::perl_matcher(BidiIter
|
||||
m_stack_base = 0;
|
||||
m_backup_state = 0;
|
||||
#endif
|
||||
// find the value to use for matching word boundaries:
|
||||
const char_type w = static_cast<char_type>('w');
|
||||
m_word_mask = traits_inst.lookup_classname(&w, &w+1);
|
||||
// find bitmask to use for matching '.':
|
||||
match_any_mask = static_cast<unsigned char>((f & match_not_dot_newline) ? re_detail::test_not_newline : re_detail::test_newline);
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
void perl_matcher<BidiIterator, Allocator, traits, Allocator2>::estimate_max_state_count(std::random_access_iterator_tag*)
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
void perl_matcher<BidiIterator, Allocator, traits>::estimate_max_state_count(std::random_access_iterator_tag*)
|
||||
{
|
||||
static const difference_type k = 100000;
|
||||
difference_type dist = boost::re_detail::distance(base, last);
|
||||
traits_size_type states = static_cast<traits_size_type>(re.size());
|
||||
states *= states;
|
||||
difference_type lim = (std::numeric_limits<difference_type>::max)() - 100000 - states;
|
||||
if(dist > (difference_type)(lim / states))
|
||||
max_state_count = lim;
|
||||
difference_type lim = ((std::numeric_limits<difference_type>::max)() - k) / states;
|
||||
if(dist >= lim)
|
||||
max_state_count = (std::numeric_limits<difference_type>::max)();
|
||||
else
|
||||
max_state_count = 100000 + states * dist;
|
||||
max_state_count = k + states * dist;
|
||||
}
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
void perl_matcher<BidiIterator, Allocator, traits, Allocator2>::estimate_max_state_count(void*)
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
void perl_matcher<BidiIterator, Allocator, traits>::estimate_max_state_count(void*)
|
||||
{
|
||||
// we don't know how long the sequence is:
|
||||
max_state_count = BOOST_REGEX_MAX_STATE_COUNT;
|
||||
}
|
||||
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::protected_call(
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::protected_call(
|
||||
protected_proc_type proc)
|
||||
{
|
||||
/*
|
||||
__try{
|
||||
return (this->*proc)();
|
||||
}__except(EXCEPTION_STACK_OVERFLOW == GetExceptionCode())
|
||||
@ -103,24 +113,30 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::protected_call(
|
||||
reset_stack_guard_page();
|
||||
}
|
||||
// we only get here after a stack overflow:
|
||||
raise_error<traits>(traits_inst, REG_E_MEMORY);
|
||||
raise_error<traits>(traits_inst, regex_constants::error_size);
|
||||
// and we never really get here at all:
|
||||
return false;
|
||||
*/
|
||||
::boost::re_detail::concrete_protected_call
|
||||
<perl_matcher<BidiIterator, Allocator, traits> >
|
||||
obj(this, proc);
|
||||
return obj.execute();
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match()
|
||||
{
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
return protected_call(&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_imp);
|
||||
return protected_call(&perl_matcher<BidiIterator, Allocator, traits>::match_imp);
|
||||
#else
|
||||
return match_imp();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_imp()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_imp()
|
||||
{
|
||||
// initialise our stack if we are non-recursive:
|
||||
#ifdef BOOST_REGEX_NON_RECURSIVE
|
||||
@ -158,28 +174,28 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_imp()
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::find()
|
||||
{
|
||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||
return protected_call(&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_imp);
|
||||
return protected_call(&perl_matcher<BidiIterator, Allocator, traits>::find_imp);
|
||||
#else
|
||||
return find_imp();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_imp()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::find_imp()
|
||||
{
|
||||
static matcher_proc_type const s_find_vtable[7] =
|
||||
{
|
||||
&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_any,
|
||||
&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_word,
|
||||
&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_line,
|
||||
&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_buf,
|
||||
&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_prefix,
|
||||
&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_lit,
|
||||
&perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_lit,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_any,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_word,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_line,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_buf,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::match_prefix,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_lit,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::find_restart_lit,
|
||||
};
|
||||
|
||||
// initialise our stack if we are non-recursive:
|
||||
@ -197,7 +213,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_imp()
|
||||
// reset our state machine:
|
||||
position = base;
|
||||
search_base = base;
|
||||
pstate = access::first(re);
|
||||
pstate = re.get_first_state();
|
||||
m_presult->set_size((m_match_flags & match_nosubs) ? 1 : re.mark_count(), base, last);
|
||||
m_presult->set_base(base);
|
||||
m_match_flags |= regex_constants::match_init;
|
||||
@ -230,7 +246,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_imp()
|
||||
// find out what kind of expression we have:
|
||||
unsigned type = (m_match_flags & match_continuous) ?
|
||||
static_cast<unsigned int>(regbase::restart_continue)
|
||||
: static_cast<unsigned int>(access::restart_type(re));
|
||||
: static_cast<unsigned int>(re.get_restart_type());
|
||||
|
||||
// call the appropriate search routine:
|
||||
matcher_proc_type proc = s_find_vtable[type];
|
||||
@ -249,12 +265,12 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_imp()
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_prefix()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_prefix()
|
||||
{
|
||||
m_has_partial_match = false;
|
||||
m_has_found_match = false;
|
||||
pstate = access::first(re);
|
||||
pstate = re.get_first_state();
|
||||
m_presult->set_first(position);
|
||||
restart = position;
|
||||
match_all_states();
|
||||
@ -282,8 +298,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_prefix()
|
||||
return m_has_found_match;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_endmark()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_endmark()
|
||||
{
|
||||
int index = static_cast<const re_brace*>(pstate)->index;
|
||||
if(index > 0)
|
||||
@ -291,7 +307,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_endmark()
|
||||
if((m_match_flags & match_nosubs) == 0)
|
||||
m_presult->set_second(position, index);
|
||||
}
|
||||
else if(index < 0)
|
||||
else if((index < 0) && (index != -4))
|
||||
{
|
||||
// matched forward lookahead:
|
||||
pstate = 0;
|
||||
@ -301,8 +317,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_endmark()
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_literal()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_literal()
|
||||
{
|
||||
unsigned int len = static_cast<const re_literal*>(pstate)->length;
|
||||
const char_type* what = reinterpret_cast<const char_type*>(static_cast<const re_literal*>(pstate) + 1);
|
||||
@ -318,8 +334,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_literal()
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_start_line()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_start_line()
|
||||
{
|
||||
if(position == base)
|
||||
{
|
||||
@ -341,13 +357,13 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_start_line
|
||||
--t;
|
||||
if(position != last)
|
||||
{
|
||||
if(traits_inst.is_separator(*t) && !((*t == '\r') && (*position == '\n')) )
|
||||
if(is_separator(*t) && !((*t == static_cast<char_type>('\r')) && (*position == static_cast<char_type>('\n'))) )
|
||||
{
|
||||
pstate = pstate->next.p;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(traits_inst.is_separator(*t))
|
||||
else if(is_separator(*t))
|
||||
{
|
||||
pstate = pstate->next.p;
|
||||
return true;
|
||||
@ -355,22 +371,22 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_start_line
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_end_line()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_end_line()
|
||||
{
|
||||
if(position != last)
|
||||
{
|
||||
if(m_match_flags & match_single_line)
|
||||
return false;
|
||||
// we're not yet at the end so *first is always valid:
|
||||
if(traits_inst.is_separator(*position))
|
||||
if(is_separator(*position))
|
||||
{
|
||||
if((position != base) || (m_match_flags & match_prev_avail))
|
||||
{
|
||||
// check that we're not in the middle of \r\n sequence
|
||||
BidiIterator t(position);
|
||||
--t;
|
||||
if((*t == '\r') && (*position == '\n'))
|
||||
if((*t == static_cast<char_type>('\r')) && (*position == static_cast<char_type>('\n')))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -387,12 +403,12 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_end_line()
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_wild()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_wild()
|
||||
{
|
||||
if(position == last)
|
||||
return false;
|
||||
if(traits_inst.is_separator(*position) && (m_match_flags & match_not_dot_newline))
|
||||
if(is_separator(*position) && ((match_any_mask & static_cast<const re_dot*>(pstate)->mask) == 0))
|
||||
return false;
|
||||
if((*position == char_type(0)) && (m_match_flags & match_not_dot_null))
|
||||
return false;
|
||||
@ -401,8 +417,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_wild()
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_match()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_match()
|
||||
{
|
||||
if((m_match_flags & match_not_null) && (position == (*m_presult)[0].first))
|
||||
return false;
|
||||
@ -430,17 +446,17 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_match()
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_word_boundary()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_word_boundary()
|
||||
{
|
||||
bool b; // indcates whether next character is a word character
|
||||
if(position != last)
|
||||
{
|
||||
// prev and this character must be opposites:
|
||||
#if defined(BOOST_REGEX_USE_C_LOCALE) && defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ < 95)
|
||||
b = traits::is_class(*position, traits::char_class_word);
|
||||
b = traits::isctype(*position, m_word_mask);
|
||||
#else
|
||||
b = traits_inst.is_class(*position, traits::char_class_word);
|
||||
b = traits_inst.isctype(*position, m_word_mask);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
@ -457,7 +473,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_word_bound
|
||||
else
|
||||
{
|
||||
--position;
|
||||
b ^= traits_inst.is_class(*position, traits::char_class_word);
|
||||
b ^= traits_inst.isctype(*position, m_word_mask);
|
||||
++position;
|
||||
}
|
||||
if(b)
|
||||
@ -468,13 +484,13 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_word_bound
|
||||
return false; // no match if we get to here...
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_within_word()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_within_word()
|
||||
{
|
||||
if(position == last)
|
||||
return false;
|
||||
// both prev and this character must be traits::char_class_word:
|
||||
if(traits_inst.is_class(*position, traits::char_class_word))
|
||||
// both prev and this character must be m_word_mask:
|
||||
if(traits_inst.isctype(*position, m_word_mask))
|
||||
{
|
||||
bool b;
|
||||
if((position == base) && ((m_match_flags & match_prev_avail) == 0))
|
||||
@ -482,7 +498,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_within_wor
|
||||
else
|
||||
{
|
||||
--position;
|
||||
b = traits_inst.is_class(*position, traits::char_class_word);
|
||||
b = traits_inst.isctype(*position, m_word_mask);
|
||||
++position;
|
||||
}
|
||||
if(b)
|
||||
@ -494,12 +510,12 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_within_wor
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_word_start()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_word_start()
|
||||
{
|
||||
if(position == last)
|
||||
return false; // can't be starting a word if we're already at the end of input
|
||||
if(!traits_inst.is_class(*position, traits::char_class_word))
|
||||
if(!traits_inst.isctype(*position, m_word_mask))
|
||||
return false; // next character isn't a word character
|
||||
if((position == base) && ((m_match_flags & match_prev_avail) == 0))
|
||||
{
|
||||
@ -511,7 +527,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_word_start
|
||||
// otherwise inside buffer:
|
||||
BidiIterator t(position);
|
||||
--t;
|
||||
if(traits_inst.is_class(*t, traits::char_class_word))
|
||||
if(traits_inst.isctype(*t, m_word_mask))
|
||||
return false; // previous character not non-word
|
||||
}
|
||||
// OK we have a match:
|
||||
@ -519,14 +535,14 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_word_start
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_word_end()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_word_end()
|
||||
{
|
||||
if((position == base) && ((m_match_flags & match_prev_avail) == 0))
|
||||
return false; // start of buffer can't be end of word
|
||||
BidiIterator t(position);
|
||||
--t;
|
||||
if(traits_inst.is_class(*t, traits::char_class_word) == false)
|
||||
if(traits_inst.isctype(*t, m_word_mask) == false)
|
||||
return false; // previous character wasn't a word character
|
||||
|
||||
if(position == last)
|
||||
@ -537,15 +553,15 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_word_end()
|
||||
else
|
||||
{
|
||||
// otherwise inside buffer:
|
||||
if(traits_inst.is_class(*position, traits::char_class_word))
|
||||
if(traits_inst.isctype(*position, m_word_mask))
|
||||
return false; // next character is a word character
|
||||
}
|
||||
pstate = pstate->next.p;
|
||||
return true; // if we fall through to here then we've succeeded
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_buffer_start()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_buffer_start()
|
||||
{
|
||||
if((position != base) || (m_match_flags & match_not_bob))
|
||||
return false;
|
||||
@ -554,8 +570,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_buffer_sta
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_buffer_end()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_buffer_end()
|
||||
{
|
||||
if((position != last) || (m_match_flags & match_not_eob))
|
||||
return false;
|
||||
@ -564,8 +580,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_buffer_end
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_backref()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_backref()
|
||||
{
|
||||
// compare with what we previously matched:
|
||||
BidiIterator i = (*m_presult)[static_cast<const re_brace*>(pstate)->index].first;
|
||||
@ -581,13 +597,14 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_backref()
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_long_set()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set()
|
||||
{
|
||||
typedef typename traits::char_class_type char_class_type;
|
||||
// let the traits class do the work:
|
||||
if(position == last)
|
||||
return false;
|
||||
BidiIterator t = re_is_set_member(position, last, static_cast<const re_set_long*>(pstate), re);
|
||||
BidiIterator t = re_is_set_member(position, last, static_cast<const re_set_long<char_class_type>*>(pstate), re.get_data(), icase);
|
||||
if(t != position)
|
||||
{
|
||||
pstate = pstate->next.p;
|
||||
@ -597,12 +614,12 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_long_set()
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_set()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_set()
|
||||
{
|
||||
if(position == last)
|
||||
return false;
|
||||
if(static_cast<const re_set*>(pstate)->_map[(traits_uchar_type)traits_inst.translate(*position, icase)])
|
||||
if(static_cast<const re_set*>(pstate)->_map[static_cast<unsigned char>(traits_inst.translate(*position, icase))])
|
||||
{
|
||||
pstate = pstate->next.p;
|
||||
++position;
|
||||
@ -611,42 +628,42 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_set()
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_jump()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_jump()
|
||||
{
|
||||
pstate = static_cast<const re_jump*>(pstate)->alt.p;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_combining()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_combining()
|
||||
{
|
||||
if(position == last)
|
||||
return false;
|
||||
if(traits_inst.is_combining(traits_inst.translate(*position, icase)))
|
||||
if(is_combining(traits_inst.translate(*position, icase)))
|
||||
return false;
|
||||
++position;
|
||||
while((position != last) && traits_inst.is_combining(traits_inst.translate(*position, icase)))
|
||||
while((position != last) && is_combining(traits_inst.translate(*position, icase)))
|
||||
++position;
|
||||
pstate = pstate->next.p;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_soft_buffer_end()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_soft_buffer_end()
|
||||
{
|
||||
if(m_match_flags & match_not_eob)
|
||||
return false;
|
||||
BidiIterator p(position);
|
||||
while((p != last) && traits_inst.is_separator(traits_inst.translate(*p, icase)))++p;
|
||||
while((p != last) && is_separator(traits_inst.translate(*p, icase)))++p;
|
||||
if(p != last)
|
||||
return false;
|
||||
pstate = pstate->next.p;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_restart_continue()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_restart_continue()
|
||||
{
|
||||
if(position == search_base)
|
||||
{
|
||||
@ -656,23 +673,53 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_restart_co
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_any()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_backstep()
|
||||
{
|
||||
std::ptrdiff_t maxlen = ::boost::re_detail::distance(search_base, position);
|
||||
if(maxlen < static_cast<const re_brace*>(pstate)->index)
|
||||
return false;
|
||||
std::advance(position, -static_cast<const re_brace*>(pstate)->index);
|
||||
pstate = pstate->next.p;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
inline bool perl_matcher<BidiIterator, Allocator, traits>::match_assert_backref()
|
||||
{
|
||||
// return true if marked sub-expression N has been matched:
|
||||
bool result = (*m_presult)[static_cast<const re_brace*>(pstate)->index].matched;
|
||||
pstate = pstate->next.p;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case()
|
||||
{
|
||||
// change our case sensitivity:
|
||||
this->icase = static_cast<const re_case*>(pstate)->icase;
|
||||
pstate = pstate->next.p;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_any()
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
const unsigned char* _map = access::get_map(re);
|
||||
const unsigned char* _map = re.get_map();
|
||||
while(true)
|
||||
{
|
||||
// skip everything we can't match:
|
||||
while((position != last) && !access::can_start(*position, _map, (unsigned char)mask_any) )
|
||||
while((position != last) && !can_start(*position, _map, (unsigned char)mask_any) )
|
||||
++position;
|
||||
if(position == last)
|
||||
{
|
||||
// run out of characters, try a null match if possible:
|
||||
if(access::first(re)->can_be_null)
|
||||
if(re.can_be_null())
|
||||
return match_prefix();
|
||||
break;
|
||||
}
|
||||
@ -689,29 +736,29 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_any
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_word()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_word()
|
||||
{
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
// do search optimised for word starts:
|
||||
const unsigned char* _map = access::get_map(re);
|
||||
const unsigned char* _map = re.get_map();
|
||||
if((m_match_flags & match_prev_avail) || (position != base))
|
||||
--position;
|
||||
else if(match_prefix())
|
||||
return true;
|
||||
do
|
||||
{
|
||||
while((position != last) && traits_inst.is_class(*position, traits::char_class_word))
|
||||
while((position != last) && traits_inst.isctype(*position, m_word_mask))
|
||||
++position;
|
||||
while((position != last) && !traits_inst.is_class(*position, traits::char_class_word))
|
||||
while((position != last) && !traits_inst.isctype(*position, m_word_mask))
|
||||
++position;
|
||||
if(position == last)
|
||||
break;
|
||||
|
||||
if(access::can_start(*position, _map, (unsigned char)mask_any) )
|
||||
if(can_start(*position, _map, (unsigned char)mask_any) )
|
||||
{
|
||||
if(match_prefix())
|
||||
return true;
|
||||
@ -725,28 +772,28 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_wor
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_line()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_line()
|
||||
{
|
||||
// do search optimised for line starts:
|
||||
const unsigned char* _map = access::get_map(re);
|
||||
const unsigned char* _map = re.get_map();
|
||||
if(match_prefix())
|
||||
return true;
|
||||
while(position != last)
|
||||
{
|
||||
while((position != last) && (*position != '\n'))
|
||||
while((position != last) && !is_separator(*position))
|
||||
++position;
|
||||
if(position == last)
|
||||
return false;
|
||||
++position;
|
||||
if(position == last)
|
||||
{
|
||||
if((access::first(re)->can_be_null) && match_prefix())
|
||||
if(re.can_be_null() && match_prefix())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if( access::can_start(*position, _map, (unsigned char)mask_any) )
|
||||
if( can_start(*position, _map, (unsigned char)mask_any) )
|
||||
{
|
||||
if(match_prefix())
|
||||
return true;
|
||||
@ -758,23 +805,24 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_lin
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_buf()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_buf()
|
||||
{
|
||||
if((position == base) && ((m_match_flags & match_not_bob) == 0))
|
||||
return match_prefix();
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_lit()
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_lit()
|
||||
{
|
||||
#if 0
|
||||
if(position == last)
|
||||
return false; // can't possibly match if we're at the end already
|
||||
|
||||
unsigned type = (m_match_flags & match_continuous) ?
|
||||
static_cast<unsigned int>(regbase::restart_continue)
|
||||
: static_cast<unsigned int>(access::restart_type(re));
|
||||
: static_cast<unsigned int>(re.get_restart_type());
|
||||
|
||||
const kmp_info<char_type>* info = access::get_kmp(re);
|
||||
int len = info->len;
|
||||
@ -823,6 +871,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find_restart_lit
|
||||
std::advance(position, -j);
|
||||
return match_prefix();
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user