mirror of
https://github.com/boostorg/regex.git
synced 2025-07-16 13:52:17 +02:00
Change "id" to "idx" to be Objective C++ compatible.
Fixes #2306. Fixes #4132. Fixes #4191. [SVN r61789]
This commit is contained in:
@ -769,14 +769,14 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
|
||||
case syntax_element_assert_backref:
|
||||
{
|
||||
// just check that the index is valid:
|
||||
int id = static_cast<const re_brace*>(state)->index;
|
||||
if(id < 0)
|
||||
int idx = static_cast<const re_brace*>(state)->index;
|
||||
if(idx < 0)
|
||||
{
|
||||
id = -id-1;
|
||||
if(id >= 10000)
|
||||
idx = -idx-1;
|
||||
if(idx >= 10000)
|
||||
{
|
||||
id = m_pdata->get_id(id);
|
||||
if(id <= 0)
|
||||
idx = m_pdata->get_id(idx);
|
||||
if(idx <= 0)
|
||||
{
|
||||
// check of sub-expression that doesn't exist:
|
||||
if(0 == this->m_pdata->m_status) // update the error code if not already set
|
||||
@ -804,12 +804,12 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
|
||||
{
|
||||
bool ok = false;
|
||||
re_syntax_base* p = base;
|
||||
std::ptrdiff_t id = static_cast<re_jump*>(state)->alt.i;
|
||||
if(id > 10000)
|
||||
id = m_pdata->get_id(id);
|
||||
std::ptrdiff_t idx = static_cast<re_jump*>(state)->alt.i;
|
||||
if(idx > 10000)
|
||||
idx = m_pdata->get_id(idx);
|
||||
while(p)
|
||||
{
|
||||
if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == id))
|
||||
if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == idx))
|
||||
{
|
||||
//
|
||||
// We've found the target of the recursion, set the jump target:
|
||||
@ -833,7 +833,7 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
|
||||
next_rep_id = static_cast<re_repeat*>(p)->state_id;
|
||||
break;
|
||||
case syntax_element_endmark:
|
||||
if(static_cast<const re_brace*>(p)->index == id)
|
||||
if(static_cast<const re_brace*>(p)->index == idx)
|
||||
next_rep_id = -1;
|
||||
break;
|
||||
default:
|
||||
@ -1543,3 +1543,4 @@ void basic_regex_creator<charT, traits>::probe_leading_repeat(re_syntax_base* st
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -336,7 +336,7 @@ struct recursion_info
|
||||
{
|
||||
typedef typename Results::value_type value_type;
|
||||
typedef typename value_type::iterator iterator;
|
||||
int id;
|
||||
int idx;
|
||||
const re_syntax_base* preturn_address;
|
||||
Results results;
|
||||
repeater_count<iterator>* repeater_stack;
|
||||
@ -522,7 +522,7 @@ private:
|
||||
void push_repeater_count(int i, repeater_count<BidiIterator>** s);
|
||||
void push_single_repeat(std::size_t c, const re_repeat* r, BidiIterator last_position, int state_id);
|
||||
void push_non_greedy_repeat(const re_syntax_base* ps);
|
||||
void push_recursion(int id, const re_syntax_base* p, results_type* presults);
|
||||
void push_recursion(int idx, const re_syntax_base* p, results_type* presults);
|
||||
void push_recursion_pop();
|
||||
|
||||
// pointer to base of stack:
|
||||
|
@ -732,10 +732,10 @@ inline bool perl_matcher<BidiIterator, Allocator, traits>::match_assert_backref(
|
||||
{
|
||||
// Have we recursed into subexpression "index"?
|
||||
// If index == 0 then check for any recursion at all, otherwise for recursion to -index-1.
|
||||
int id = -index-1;
|
||||
if(id >= 10000)
|
||||
id = re.get_data().get_id(id);
|
||||
result = !recursion_stack.empty() && ((recursion_stack.back().id == id) || (index == 0));
|
||||
int idx = -index-1;
|
||||
if(idx >= 10000)
|
||||
idx = re.get_data().get_id(idx);
|
||||
result = !recursion_stack.empty() && ((recursion_stack.back().idx == idx) || (index == 0));
|
||||
pstate = pstate->next.p;
|
||||
}
|
||||
return result;
|
||||
|
@ -130,8 +130,8 @@ struct saved_single_repeat : public saved_state
|
||||
template <class Results>
|
||||
struct saved_recursion : public saved_state
|
||||
{
|
||||
saved_recursion(int id, const re_syntax_base* p, Results* pr)
|
||||
: saved_state(14), recursion_id(id), preturn_address(p), results(*pr)
|
||||
saved_recursion(int idx, const re_syntax_base* p, Results* pr)
|
||||
: saved_state(14), recursion_id(idx), preturn_address(p), results(*pr)
|
||||
{}
|
||||
int recursion_id;
|
||||
const re_syntax_base* preturn_address;
|
||||
@ -329,7 +329,7 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_single_repeat(st
|
||||
}
|
||||
|
||||
template <class BidiIterator, class Allocator, class traits>
|
||||
inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion(int id, const re_syntax_base* p, results_type* presults)
|
||||
inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion(int idx, const re_syntax_base* p, results_type* presults)
|
||||
{
|
||||
saved_recursion<results_type>* pmp = static_cast<saved_recursion<results_type>*>(m_backup_state);
|
||||
--pmp;
|
||||
@ -339,7 +339,7 @@ inline void perl_matcher<BidiIterator, Allocator, traits>::push_recursion(int id
|
||||
pmp = static_cast<saved_recursion<results_type>*>(m_backup_state);
|
||||
--pmp;
|
||||
}
|
||||
(void) new (pmp)saved_recursion<results_type>(id, p, presults);
|
||||
(void) new (pmp)saved_recursion<results_type>(idx, p, presults);
|
||||
m_backup_state = pmp;
|
||||
}
|
||||
|
||||
@ -910,7 +910,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion()
|
||||
push_repeater_count(static_cast<const re_recurse*>(pstate)->state_id, &next_count);
|
||||
}
|
||||
pstate = static_cast<const re_jump*>(pstate)->alt.p;
|
||||
recursion_stack.back().id = static_cast<const re_brace*>(pstate)->index;
|
||||
recursion_stack.back().idx = static_cast<const re_brace*>(pstate)->index;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -928,11 +928,11 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_endmark()
|
||||
}
|
||||
if(!recursion_stack.empty())
|
||||
{
|
||||
if(index == recursion_stack.back().id)
|
||||
if(index == recursion_stack.back().idx)
|
||||
{
|
||||
pstate = recursion_stack.back().preturn_address;
|
||||
*m_presult = recursion_stack.back().results;
|
||||
push_recursion(recursion_stack.back().id, recursion_stack.back().preturn_address, &recursion_stack.back().results);
|
||||
push_recursion(recursion_stack.back().idx, recursion_stack.back().preturn_address, &recursion_stack.back().results);
|
||||
recursion_stack.pop_back();
|
||||
}
|
||||
}
|
||||
@ -952,10 +952,10 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match()
|
||||
{
|
||||
if(!recursion_stack.empty())
|
||||
{
|
||||
BOOST_ASSERT(0 == recursion_stack.back().id);
|
||||
BOOST_ASSERT(0 == recursion_stack.back().idx);
|
||||
pstate = recursion_stack.back().preturn_address;
|
||||
*m_presult = recursion_stack.back().results;
|
||||
push_recursion(recursion_stack.back().id, recursion_stack.back().preturn_address, &recursion_stack.back().results);
|
||||
push_recursion(recursion_stack.back().idx, recursion_stack.back().preturn_address, &recursion_stack.back().results);
|
||||
recursion_stack.pop_back();
|
||||
return true;
|
||||
}
|
||||
@ -1523,7 +1523,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::unwind_recursion(bool r)
|
||||
if(!r)
|
||||
{
|
||||
recursion_stack.push_back(recursion_info<results_type>());
|
||||
recursion_stack.back().id = pmp->recursion_id;
|
||||
recursion_stack.back().idx = pmp->recursion_id;
|
||||
recursion_stack.back().preturn_address = pmp->preturn_address;
|
||||
recursion_stack.back().results = pmp->results;
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion()
|
||||
recursion_stack.back().results = *m_presult;
|
||||
recursion_stack.back().repeater_stack = next_count;
|
||||
pstate = static_cast<const re_jump*>(pstate)->alt.p;
|
||||
recursion_stack.back().id = static_cast<const re_brace*>(pstate)->index;
|
||||
recursion_stack.back().idx = static_cast<const re_brace*>(pstate)->index;
|
||||
|
||||
repeater_count<BidiIterator>* saved = next_count;
|
||||
repeater_count<BidiIterator> r(&next_count); // resets all repeat counts since we're recursing and starting fresh on those
|
||||
@ -897,7 +897,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_endmark()
|
||||
}
|
||||
if(!recursion_stack.empty())
|
||||
{
|
||||
if(index == recursion_stack.back().id)
|
||||
if(index == recursion_stack.back().idx)
|
||||
{
|
||||
recursion_info<results_type> saved = recursion_stack.back();
|
||||
recursion_stack.pop_back();
|
||||
@ -929,7 +929,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match()
|
||||
{
|
||||
if(!recursion_stack.empty())
|
||||
{
|
||||
BOOST_ASSERT(0 == recursion_stack.back().id);
|
||||
BOOST_ASSERT(0 == recursion_stack.back().idx);
|
||||
const re_syntax_base* saved_state = pstate = recursion_stack.back().preturn_address;
|
||||
*m_presult = recursion_stack.back().results;
|
||||
recursion_stack.pop_back();
|
||||
|
Reference in New Issue
Block a user