Merge changes in Trunk:

Simplify regex_timer to eliminate regression failure.
  Rename extern "C" function to have a "boost_" prefix.
  Fix recursive-expression related bug, and update tests to match.

[SVN r58885]
This commit is contained in:
John Maddock
2010-01-11 09:55:40 +00:00
parent e41acbc33f
commit fc6408426d
9 changed files with 74 additions and 19 deletions

View File

@ -140,7 +140,7 @@ inline bool scoped_static_mutex_lock::locked()const
namespace boost{
class BOOST_REGEX_DECL scoped_static_mutex_lock;
extern "C" BOOST_REGEX_DECL void free_static_mutex();
extern "C" BOOST_REGEX_DECL void boost_regex_free_static_mutex();
class BOOST_REGEX_DECL static_mutex
{

View File

@ -811,8 +811,43 @@ void basic_regex_creator<charT, traits>::fixup_recursions(re_syntax_base* state)
{
if((p->type == syntax_element_startmark) && (static_cast<re_brace*>(p)->index == id))
{
//
// We've found the target of the recursion, set the jump target:
//
static_cast<re_jump*>(state)->alt.p = p;
ok = true;
//
// Now scan the target for nested repeats:
//
p = p->next.p;
int next_rep_id = 0;
while(p)
{
switch(p->type)
{
case syntax_element_rep:
case syntax_element_dot_rep:
case syntax_element_char_rep:
case syntax_element_short_set_rep:
case syntax_element_long_set_rep:
next_rep_id = static_cast<re_repeat*>(p)->state_id;
break;
case syntax_element_endmark:
if(static_cast<const re_brace*>(p)->index == id)
next_rep_id = -1;
break;
default:
break;
}
if(next_rep_id)
break;
p = p->next.p;
}
if(next_rep_id > 0)
{
static_cast<re_recurse*>(state)->state_id = next_rep_id - 1;
}
break;
}
p = p->next.p;

View File

@ -1939,7 +1939,9 @@ bool basic_regex_parser<charT, traits>::parse_perl_extension()
}
insert_recursion:
pb->index = markid = 0;
static_cast<re_jump*>(this->append_state(syntax_element_recurse, sizeof(re_jump)))->alt.i = v;
re_recurse* pr = static_cast<re_recurse*>(this->append_state(syntax_element_recurse, sizeof(re_recurse)));
pr->alt.i = v;
pr->state_id = 0;
static_cast<re_case*>(
this->append_state(syntax_element_toggle_case, sizeof(re_case))
)->icase = this->flags() & regbase::icase;

View File

@ -277,10 +277,15 @@ public:
else
{
repeater_count* p = next;
while(p->state_id != state_id)
while(p && (p->state_id != state_id))
p = p->next;
count = p->count;
start_pos = p->start_pos;
if(p)
{
count = p->count;
start_pos = p->start_pos;
}
else
count = 0;
}
}
~repeater_count()

View File

@ -904,10 +904,15 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion()
}
recursion_stack[recursion_stack_position].preturn_address = pstate->next.p;
recursion_stack[recursion_stack_position].results = *m_presult;
if(static_cast<const re_recurse*>(pstate)->state_id > 0)
{
push_repeater_count(static_cast<const re_recurse*>(pstate)->state_id, &next_count);
}
pstate = static_cast<const re_jump*>(pstate)->alt.p;
recursion_stack[recursion_stack_position].id = static_cast<const re_brace*>(pstate)->index;
++recursion_stack_position;
//BOOST_ASSERT(recursion_stack[recursion_stack_position-1].id);
return true;
}

View File

@ -248,6 +248,14 @@ struct re_repeat : public re_alt
bool greedy; // True if this is a greedy repeat
};
/*** struct re_recurse ************************************************
Recurse to a particular subexpression.
**********************************************************************/
struct re_recurse : public re_jump
{
int state_id; // identifier of first nested repeat within the recursion.
};
/*** enum re_jump_size_type *******************************************
Provides compiled size of re_jump structure (allowing for trailing alignment).
We provide this so we know how manybytes to insert when constructing the machine