Update of /cvsroot/boost/boost/boost/xpressive/detail/core
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv20055/detail/core
Modified Files:
flow_control.hpp state.hpp
Log Message:
add support for (?R) for self-recursive dynamic regexes
Index: flow_control.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/detail/core/flow_control.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- flow_control.hpp 22 Oct 2006 05:11:38 -0000 1.4
+++ flow_control.hpp 4 Mar 2007 18:07:03 -0000 1.5
@@ -32,16 +32,21 @@
, matchable<BidiIter> const &next
)
{
+ // avoid infinite recursion
+ // BUGBUG this only catches direct infinite recursion, like
sregex::compile("(?R)"), but
+ // not indirect infinite recursion where two rules invoke each other
recursively.
+ if(state.is_active_regex(impl) && state.cur_ == state.sub_match(0).begin_)
+ {
+ return next.match(state);
+ }
+
// save state
match_context<BidiIter> context = state.push_context(impl, next, context);
detail::ignore_unused(context);
- // match the nested regex
- bool success = impl.xpr_->match(state);
-
- // uninitialize the match context (reclaims the sub_match objects if
necessary)
- state.pop_context(impl, success);
- return success;
+ // match the nested regex and uninitialize the match context
+ // (reclaims the sub_match objects if necessary)
+ return state.pop_context(impl, impl.xpr_->match(state));
}
///////////////////////////////////////////////////////////////////////////////
Index: state.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/detail/core/state.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- state.hpp 18 Apr 2006 07:52:49 -0000 1.8
+++ state.hpp 4 Mar 2007 18:07:03 -0000 1.9
@@ -180,7 +180,7 @@
///////////////////////////////////////////////////////////////////////////////
// pop_context
// called after a nested match failed to restore the context
- void pop_context(regex_impl const &impl, bool success)
+ bool pop_context(regex_impl const &impl, bool success)
{
match_context &context = *this->context_.prev_context_;
if(!success)
@@ -198,6 +198,7 @@
match_results &results = *this->context_.results_ptr_;
this->sub_matches_ =
access::get_sub_matches(access::get_sub_match_vector(results));
this->mark_count_ = results.size();
+ return success;
}
///////////////////////////////////////////////////////////////////////////////
@@ -222,6 +223,12 @@
return this->cur_ == this->end_ && this->found_partial_match();
}
+ // is this the regex that is currently executing?
+ bool is_active_regex(regex_impl const &impl) const
+ {
+ return impl.xpr_.get() == this->context_.results_ptr_->regex_id();
+ }
+
// fetch the n-th sub_match
sub_match_impl &sub_match(int n)
{
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs