mirror of
https://github.com/boostorg/regex.git
synced 2025-07-22 16:47:17 +02:00
Fix case-sensitivity change behaviour.
See https://svn.boost.org/trac/boost/ticket/11205. Update docs to match.
This commit is contained in:
@ -537,6 +537,7 @@ private:
|
||||
bool unwind_recursion_pop(bool);
|
||||
bool unwind_commit(bool);
|
||||
bool unwind_then(bool);
|
||||
bool unwind_case(bool);
|
||||
void destroy_single_repeat();
|
||||
void push_matched_paren(int index, const sub_match<BidiIterator>& sub);
|
||||
void push_recursion_stopper();
|
||||
@ -547,6 +548,7 @@ private:
|
||||
void push_non_greedy_repeat(const re_syntax_base* ps);
|
||||
void push_recursion(int idx, const re_syntax_base* p, results_type* presults);
|
||||
void push_recursion_pop();
|
||||
void push_case_change(bool);
|
||||
|
||||
// pointer to base of stack:
|
||||
saved_state* m_stack_base;
|
||||
|
@ -793,15 +793,6 @@ inline bool perl_matcher<BidiIterator, Allocator, traits>::match_assert_backref(
|
||||
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>::match_fail()
|
||||
{
|
||||
|
@ -138,6 +138,12 @@ struct saved_recursion : public saved_state
|
||||
Results results;
|
||||
};
|
||||
|
||||
struct saved_change_case : public saved_state
|
||||
{
|
||||
bool icase;
|
||||
saved_change_case(bool c) : saved_state(18), icase(c) {}
|
||||
};
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
|
||||
{
|
||||
@ -242,6 +248,22 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_matched_paren(in
|
||||
m_backup_state = pmp;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
inline void perl_matcher<BidiIterator, Allocator, traits>::push_case_change(bool c)
|
||||
{
|
||||
//BOOST_ASSERT(index);
|
||||
saved_change_case* pmp = static_cast<saved_change_case*>(m_backup_state);
|
||||
--pmp;
|
||||
if(pmp < m_stack_base)
|
||||
{
|
||||
extend_stack();
|
||||
pmp = static_cast<saved_change_case*>(m_backup_state);
|
||||
--pmp;
|
||||
}
|
||||
(void) new (pmp)saved_change_case(c);
|
||||
m_backup_state = pmp;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion_stopper()
|
||||
{
|
||||
@ -347,6 +369,16 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion(int id
|
||||
m_backup_state = pmp;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case()
|
||||
{
|
||||
// change our case sensitivity:
|
||||
push_case_change(this->icase);
|
||||
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>::match_startmark()
|
||||
{
|
||||
@ -1142,6 +1174,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind(bool have_match)
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion_pop,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::unwind_commit,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::unwind_then,
|
||||
&perl_matcher<BidiIterator, Allocator, traits>::unwind_case,
|
||||
};
|
||||
|
||||
m_recursive_result = have_match;
|
||||
@ -1170,6 +1203,16 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_end(bool)
|
||||
return false; // end of stack nothing more to search
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::unwind_case(bool)
|
||||
{
|
||||
saved_change_case* pmp = static_cast<saved_change_case*>(m_backup_state);
|
||||
icase = pmp->icase;
|
||||
boost::BOOST_REGEX_DETAIL_NS::inplace_destroy(pmp++);
|
||||
m_backup_state = pmp;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::unwind_paren(bool have_match)
|
||||
{
|
||||
|
@ -289,11 +289,13 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_alt()
|
||||
BidiIterator oldposition(position);
|
||||
const re_syntax_base* old_pstate = jmp->alt.p;
|
||||
pstate = pstate->next.p;
|
||||
bool oldcase = icase;
|
||||
m_have_then = false;
|
||||
if(!match_all_states())
|
||||
{
|
||||
pstate = old_pstate;
|
||||
position = oldposition;
|
||||
icase = oldcase;
|
||||
if(m_have_then)
|
||||
{
|
||||
m_can_backtrack = true;
|
||||
@ -1036,6 +1038,20 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_then()
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case()
|
||||
{
|
||||
// change our case sensitivity:
|
||||
bool oldcase = this->icase;
|
||||
this->icase = static_cast<const re_case*>(pstate)->icase;
|
||||
pstate = pstate->next.p;
|
||||
bool result = match_all_states();
|
||||
this->icase = oldcase;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
bool perl_matcher<BidiIterator, Allocator, traits>::skip_until_paren(int index, bool have_match)
|
||||
{
|
||||
|
Reference in New Issue
Block a user