Commit d860c842 by Paolo Carlini Committed by Paolo Carlini

regex_compiler.h: Trivial formatting / stylistic fixes.

2010-06-27  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/regex_compiler.h: Trivial formatting / stylistic fixes.
	* include/bits/regex_grep_matcher.tcc: Likewise.
	* include/bits/regex_cursor.h: Likewise.
	* include/bits/regex.h: Likewise.

From-SVN: r161462
parent 83e279c4
2010-06-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/regex_compiler.h: Trivial formatting / stylistic fixes.
* include/bits/regex_grep_matcher.tcc: Likewise.
* include/bits/regex_cursor.h: Likewise.
* include/bits/regex.h: Likewise.
2010-06-26 Paolo Carlini <paolo.carlini@oracle.com>
* testsuite/util/testsuite_hooks.h: Cast fn to bool.
......
......@@ -451,7 +451,8 @@ namespace std
*/
template<typename _Ch_traits, typename _Ch_alloc>
explicit
basic_regex(const std::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
basic_regex(const std::basic_string<_Ch_type, _Ch_traits,
_Ch_alloc>& __s,
flag_type __f = regex_constants::ECMAScript)
: _M_flags(__f),
_M_automaton(__regex::__compile(__s.begin(), __s.end(),
......
......@@ -64,11 +64,11 @@ namespace __regex
const _FwdIterT&
_M_begin() const
{ return _M_b; }
{ return _M_b; }
const _FwdIterT&
_M_end() const
{ return _M_e; }
{ return _M_e; }
bool
_M_at_end() const
......@@ -82,9 +82,9 @@ namespace __regex
// Helper funxtion to create a cursor specialized for an iterator class.
template<typename _FwdIterT>
_SpecializedCursor<_FwdIterT>
__cursor(const _FwdIterT& __b, const _FwdIterT __e)
{ return _SpecializedCursor<_FwdIterT>(__b, __e); }
inline _SpecializedCursor<_FwdIterT>
__cursor(const _FwdIterT& __b, const _FwdIterT __e)
{ return _SpecializedCursor<_FwdIterT>(__b, __e); }
} // namespace __regex
} // namespace std
......
......@@ -34,10 +34,9 @@ namespace
{
// A stack of states used in evaluating the NFA.
typedef std::stack<
std::__regex::_StateIdT,
typedef std::stack<std::__regex::_StateIdT,
std::vector<std::__regex::_StateIdT>
> _StateStack;
> _StateStack;
// Obtains the next state set given the current state set __s and the current
// input character.
......@@ -48,16 +47,16 @@ namespace
{
std::__regex::_StateSet __m;
for (std::__regex::_StateSet::const_iterator __i = __s.begin();
__i != __s.end(); ++__i)
{
if (*__i == std::__regex::_S_invalid_state_id)
continue;
const std::__regex::_State& __state = __nfa[*__i];
if (__state._M_opcode == std::__regex::_S_opcode_match
&& __state._M_matches(__p))
__i != __s.end(); ++__i)
{
if (*__i == std::__regex::_S_invalid_state_id)
continue;
const std::__regex::_State& __state = __nfa[*__i];
if (__state._M_opcode == std::__regex::_S_opcode_match
&& __state._M_matches(__p))
__m.insert(__state._M_next);
}
}
return __m;
}
......@@ -67,19 +66,19 @@ namespace
const std::__regex::_StateSet& __t)
{
if (__s.size() > 0 && __t.size() > 0)
{
std::__regex::_StateSet::const_iterator __first = __s.begin();
std::__regex::_StateSet::const_iterator __second = __t.begin();
while (__first != __s.end() && __second != __t.end())
{
if (*__first < *__second)
++__first;
else if (*__second < *__first)
++__second;
else
return true;
std::__regex::_StateSet::const_iterator __first = __s.begin();
std::__regex::_StateSet::const_iterator __second = __t.begin();
while (__first != __s.end() && __second != __t.end())
{
if (*__first < *__second)
++__first;
else if (*__second < *__first)
++__second;
else
return true;
}
}
}
return false;
}
......@@ -91,10 +90,10 @@ namespace
std::__regex::_StateSet& __e)
{
if (__e.count(__u) == 0)
{
__e.insert(__u);
__s.push(__u);
}
{
__e.insert(__u);
__s.push(__u);
}
}
} // anonymous namespace
......@@ -102,9 +101,8 @@ namespace
namespace __regex
{
inline _Grep_matcher::
_Grep_matcher(_PatternCursor& __p,
_Results& __r,
const _AutomatonPtr& __nfa,
_Grep_matcher(_PatternCursor& __p, _Results& __r,
const _AutomatonPtr& __nfa,
regex_constants::match_flag_type __flags)
: _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r)
{
......@@ -142,34 +140,34 @@ namespace __regex
{
_StateSet __e = __s;
while (!__stack.empty())
{
_StateIdT __t = __stack.top(); __stack.pop();
if (__t == _S_invalid_state_id)
continue;
// for each __u with edge from __t to __u labeled e do ...
const _State& __state = _M_nfa->operator[](__t);
switch (__state._M_opcode)
{
case _S_opcode_alternative:
__add_visited_state(__state._M_next, __stack, __e);
__add_visited_state(__state._M_alt, __stack, __e);
break;
case _S_opcode_subexpr_begin:
__add_visited_state(__state._M_next, __stack, __e);
__state._M_tagger(_M_pattern, _M_results);
break;
case _S_opcode_subexpr_end:
__add_visited_state(__state._M_next, __stack, __e);
__state._M_tagger(_M_pattern, _M_results);
_M_results._M_set_matched(__state._M_subexpr, true);
break;
case _S_opcode_accept:
__add_visited_state(__state._M_next, __stack, __e);
break;
default:
break;
_StateIdT __t = __stack.top(); __stack.pop();
if (__t == _S_invalid_state_id)
continue;
// for each __u with edge from __t to __u labeled e do ...
const _State& __state = _M_nfa->operator[](__t);
switch (__state._M_opcode)
{
case _S_opcode_alternative:
__add_visited_state(__state._M_next, __stack, __e);
__add_visited_state(__state._M_alt, __stack, __e);
break;
case _S_opcode_subexpr_begin:
__add_visited_state(__state._M_next, __stack, __e);
__state._M_tagger(_M_pattern, _M_results);
break;
case _S_opcode_subexpr_end:
__add_visited_state(__state._M_next, __stack, __e);
__state._M_tagger(_M_pattern, _M_results);
_M_results._M_set_matched(__state._M_subexpr, true);
break;
case _S_opcode_accept:
__add_visited_state(__state._M_next, __stack, __e);
break;
default:
break;
}
}
}
return __e;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment