mirror of git://gcc.gnu.org/git/gcc.git
regex.h (regex_token_iterator<>::regex_token_iterator): Fix initialization orders in initialization list and add explicit braces for...
2013-10-17 Tim Shen <timshen91@gmail.com> * include/bits/regex.h (regex_token_iterator<>::regex_token_iterator): Fix initialization orders in initialization list and add explicit braces for potentially ambiguous(actually not) `else` branch to eliminate warnings. * include/bits/regex_automaton.h (_NFA<>::_NFA): Likewise. * include/bits/regex_compiler.h (_CharMatcher<>::_CharMatcher, _BracketMatcher<>::_BracketMatcher): Likewise. * include/bits/regex_compiler.tcc (_Compiler<>::_Compiler, _Compiler<>::_M_atom): Likewise. * include/bits/regex_executor.h (_Executor<>::_Executor): Likewise. * include/bits/regex_executor.tcc (_DFSExecutor<>::_M_dfs, _Executor<>::_M_word_boundry): Likewise. * include/bits/regex_scanner.tcc (_Scanner<>::_Scanner, _Scanner<>::_M_eat_class): Likewise. * include/bits/regex.tcc (__regex_algo_impl<>, regex_iterator<>::operator++): Likewise, and remove unused typedef. From-SVN: r203798
This commit is contained in:
parent
358e1993d0
commit
ab1c993b94
|
|
@ -1,3 +1,22 @@
|
||||||
|
2013-10-17 Tim Shen <timshen91@gmail.com>
|
||||||
|
|
||||||
|
* include/bits/regex.h (regex_token_iterator<>::regex_token_iterator):
|
||||||
|
Fix initialization orders in initialization list and add explicit braces
|
||||||
|
for potentially ambiguous(actually not) `else` branch to eliminate
|
||||||
|
warnings.
|
||||||
|
* include/bits/regex_automaton.h (_NFA<>::_NFA): Likewise.
|
||||||
|
* include/bits/regex_compiler.h (_CharMatcher<>::_CharMatcher,
|
||||||
|
_BracketMatcher<>::_BracketMatcher): Likewise.
|
||||||
|
* include/bits/regex_compiler.tcc (_Compiler<>::_Compiler,
|
||||||
|
_Compiler<>::_M_atom): Likewise.
|
||||||
|
* include/bits/regex_executor.h (_Executor<>::_Executor): Likewise.
|
||||||
|
* include/bits/regex_executor.tcc (_DFSExecutor<>::_M_dfs,
|
||||||
|
_Executor<>::_M_word_boundry): Likewise.
|
||||||
|
* include/bits/regex_scanner.tcc (_Scanner<>::_Scanner,
|
||||||
|
_Scanner<>::_M_eat_class): Likewise.
|
||||||
|
* include/bits/regex.tcc (__regex_algo_impl<>,
|
||||||
|
regex_iterator<>::operator++): Likewise, and remove unused typedef.
|
||||||
|
|
||||||
2013-10-16 Tim Shen <timshen91@gmail.com>
|
2013-10-16 Tim Shen <timshen91@gmail.com>
|
||||||
|
|
||||||
* include/bits/regex.h (regex_token_iterator<>::regex_token_iterator):
|
* include/bits/regex.h (regex_token_iterator<>::regex_token_iterator):
|
||||||
|
|
|
||||||
|
|
@ -2514,7 +2514,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
|
||||||
* iterator of the same type.
|
* iterator of the same type.
|
||||||
*/
|
*/
|
||||||
regex_token_iterator()
|
regex_token_iterator()
|
||||||
: _M_position(), _M_result(nullptr), _M_suffix(), _M_n(0), _M_subs(),
|
: _M_position(), _M_subs(), _M_suffix(), _M_n(0), _M_result(nullptr),
|
||||||
_M_has_m1(false)
|
_M_has_m1(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
@ -2601,7 +2601,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
|
||||||
*/
|
*/
|
||||||
regex_token_iterator(const regex_token_iterator& __rhs)
|
regex_token_iterator(const regex_token_iterator& __rhs)
|
||||||
: _M_position(__rhs._M_position), _M_subs(__rhs._M_subs),
|
: _M_position(__rhs._M_position), _M_subs(__rhs._M_subs),
|
||||||
_M_n(__rhs._M_n), _M_result(__rhs._M_result), _M_suffix(__rhs._M_suffix),
|
_M_suffix(__rhs._M_suffix), _M_n(__rhs._M_n), _M_result(__rhs._M_result),
|
||||||
_M_has_m1(__rhs._M_has_m1)
|
_M_has_m1(__rhs._M_has_m1)
|
||||||
{
|
{
|
||||||
if (__rhs._M_result == &__rhs._M_suffix)
|
if (__rhs._M_result == &__rhs._M_suffix)
|
||||||
|
|
@ -2679,10 +2679,10 @@ _GLIBCXX_END_NAMESPACE_VERSION
|
||||||
{ return _M_result == nullptr; }
|
{ return _M_result == nullptr; }
|
||||||
|
|
||||||
_Position _M_position;
|
_Position _M_position;
|
||||||
const value_type* _M_result;
|
std::vector<int> _M_subs;
|
||||||
value_type _M_suffix;
|
value_type _M_suffix;
|
||||||
std::size_t _M_n;
|
std::size_t _M_n;
|
||||||
std::vector<int> _M_subs;
|
const value_type* _M_result;
|
||||||
|
|
||||||
// Show whether _M_subs contains -1
|
// Show whether _M_subs contains -1
|
||||||
bool _M_has_m1;
|
bool _M_has_m1;
|
||||||
|
|
|
||||||
|
|
@ -61,14 +61,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
for (auto& __it : __res)
|
for (auto& __it : __res)
|
||||||
__it.matched = false;
|
__it.matched = false;
|
||||||
|
|
||||||
typedef std::unique_ptr<_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
|
auto __executor = __get_executor<_BiIter, _Alloc, _CharT, _TraitsT,
|
||||||
_ExecutorPtr;
|
__policy>(__s, __e, __res, __re, __flags);
|
||||||
typedef _DFSExecutor<_BiIter, _Alloc, _CharT, _TraitsT> _DFSExecutorT;
|
|
||||||
typedef _BFSExecutor<_BiIter, _Alloc, _CharT, _TraitsT> _BFSExecutorT;
|
|
||||||
|
|
||||||
_ExecutorPtr __executor =
|
|
||||||
__get_executor<_BiIter, _Alloc, _CharT, _TraitsT,
|
|
||||||
__policy>(__s, __e, __res, __re, __flags);
|
|
||||||
|
|
||||||
bool __ret;
|
bool __ret;
|
||||||
if (__match_mode)
|
if (__match_mode)
|
||||||
|
|
@ -540,26 +534,29 @@ _GLIBCXX_END_NAMESPACE_VERSION
|
||||||
auto __start = _M_match[0].second;
|
auto __start = _M_match[0].second;
|
||||||
auto __prefix_first = _M_match[0].second;
|
auto __prefix_first = _M_match[0].second;
|
||||||
if (_M_match[0].first == _M_match[0].second)
|
if (_M_match[0].first == _M_match[0].second)
|
||||||
if (__start == _M_end)
|
{
|
||||||
{
|
if (__start == _M_end)
|
||||||
_M_match = value_type();
|
{
|
||||||
return *this;
|
_M_match = value_type();
|
||||||
}
|
return *this;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags
|
{
|
||||||
| regex_constants::match_not_null
|
if (regex_search(__start, _M_end, _M_match, *_M_pregex,
|
||||||
| regex_constants::match_continuous))
|
_M_flags
|
||||||
{
|
| regex_constants::match_not_null
|
||||||
_GLIBCXX_DEBUG_ASSERT(_M_match[0].matched);
|
| regex_constants::match_continuous))
|
||||||
_M_match.at(_M_match.size()).first = __prefix_first;
|
{
|
||||||
_M_match._M_in_iterator = true;
|
_GLIBCXX_DEBUG_ASSERT(_M_match[0].matched);
|
||||||
_M_match._M_begin = _M_begin;
|
_M_match.at(_M_match.size()).first = __prefix_first;
|
||||||
return *this;
|
_M_match._M_in_iterator = true;
|
||||||
}
|
_M_match._M_begin = _M_begin;
|
||||||
else
|
return *this;
|
||||||
++__start;
|
}
|
||||||
}
|
else
|
||||||
|
++__start;
|
||||||
|
}
|
||||||
|
}
|
||||||
_M_flags |= regex_constants::match_prev_avail;
|
_M_flags |= regex_constants::match_prev_avail;
|
||||||
if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags))
|
if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
_NFA(_FlagT __f)
|
_NFA(_FlagT __f)
|
||||||
: _M_flags(__f), _M_start_state(0), _M_subexpr_count(0),
|
: _M_flags(__f), _M_start_state(0), _M_subexpr_count(0),
|
||||||
_M_has_backref(false), _M_quant_count(0)
|
_M_quant_count(0), _M_has_backref(false)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
_FlagT
|
_FlagT
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|
|
||||||
explicit
|
explicit
|
||||||
_CharMatcher(_CharT __ch, const _TraitsT& __traits, _FlagT __flags)
|
_CharMatcher(_CharT __ch, const _TraitsT& __traits, _FlagT __flags)
|
||||||
: _M_ch(_M_translate(__ch)), _M_traits(__traits), _M_flags(__flags)
|
: _M_traits(__traits), _M_flags(__flags), _M_ch(_M_translate(__ch))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
@ -189,8 +189,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
_BracketMatcher(bool __is_non_matching,
|
_BracketMatcher(bool __is_non_matching,
|
||||||
const _TraitsT& __traits,
|
const _TraitsT& __traits,
|
||||||
_FlagT __flags)
|
_FlagT __flags)
|
||||||
: _M_is_non_matching(__is_non_matching), _M_traits(__traits),
|
: _M_traits(__traits), _M_class_set(0), _M_flags(__flags),
|
||||||
_M_flags(__flags), _M_class_set(0)
|
_M_is_non_matching(__is_non_matching)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
? __flags
|
? __flags
|
||||||
: __flags | regex_constants::ECMAScript),
|
: __flags | regex_constants::ECMAScript),
|
||||||
_M_traits(__traits),
|
_M_traits(__traits),
|
||||||
_M_scanner(__b, __e, _M_flags, _M_traits.getloc()),
|
|
||||||
_M_ctype(std::use_facet<std::ctype<_CharT>>(_M_traits.getloc())),
|
_M_ctype(std::use_facet<std::ctype<_CharT>>(_M_traits.getloc())),
|
||||||
|
_M_scanner(__b, __e, _M_flags, _M_traits.getloc()),
|
||||||
_M_nfa(_M_flags)
|
_M_nfa(_M_flags)
|
||||||
{
|
{
|
||||||
_StateSeqT __r(_M_nfa, _M_nfa._M_start());
|
_StateSeqT __r(_M_nfa, _M_nfa._M_start());
|
||||||
|
|
@ -318,7 +318,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
}
|
}
|
||||||
else if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
|
else if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
|
||||||
{
|
{
|
||||||
auto __mark = _M_nfa._M_sub_count();
|
|
||||||
_StateSeqT __r(_M_nfa, _M_nfa._M_insert_subexpr_begin());
|
_StateSeqT __r(_M_nfa, _M_nfa._M_insert_subexpr_begin());
|
||||||
this->_M_disjunction();
|
this->_M_disjunction();
|
||||||
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
|
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
_FlagT __flags)
|
_FlagT __flags)
|
||||||
: _M_begin(__begin),
|
: _M_begin(__begin),
|
||||||
_M_end(__end),
|
_M_end(__end),
|
||||||
_M_results(__results),
|
|
||||||
_M_re(__re),
|
_M_re(__re),
|
||||||
|
_M_results(__results),
|
||||||
_M_flags((__flags & regex_constants::match_prev_avail)
|
_M_flags((__flags & regex_constants::match_prev_avail)
|
||||||
? (__flags
|
? (__flags
|
||||||
& ~regex_constants::match_not_bol
|
& ~regex_constants::match_not_bol
|
||||||
|
|
|
||||||
|
|
@ -145,15 +145,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
if (this->_M_re._M_traits.transform(__submatch.first,
|
if (this->_M_re._M_traits.transform(__submatch.first,
|
||||||
__submatch.second)
|
__submatch.second)
|
||||||
== this->_M_re._M_traits.transform(__current, __last))
|
== this->_M_re._M_traits.transform(__current, __last))
|
||||||
if (__last != __current)
|
{
|
||||||
{
|
if (__last != __current)
|
||||||
auto __backup = __current;
|
{
|
||||||
__current = __last;
|
auto __backup = __current;
|
||||||
|
__current = __last;
|
||||||
|
__ret = _M_dfs(__state._M_next);
|
||||||
|
__current = __backup;
|
||||||
|
}
|
||||||
|
else
|
||||||
__ret = _M_dfs(__state._M_next);
|
__ret = _M_dfs(__state._M_next);
|
||||||
__current = __backup;
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
__ret = _M_dfs(__state._M_next);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _S_opcode_accept:
|
case _S_opcode_accept:
|
||||||
|
|
@ -353,15 +355,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
auto __pre = _M_current;
|
auto __pre = _M_current;
|
||||||
--__pre;
|
--__pre;
|
||||||
if (!(_M_at_begin() && _M_at_end()))
|
if (!(_M_at_begin() && _M_at_end()))
|
||||||
if (_M_at_begin())
|
{
|
||||||
__ans = _M_is_word(*_M_current)
|
if (_M_at_begin())
|
||||||
&& !(_M_flags & regex_constants::match_not_bow);
|
__ans = _M_is_word(*_M_current)
|
||||||
else if (_M_at_end())
|
&& !(_M_flags & regex_constants::match_not_bow);
|
||||||
__ans = _M_is_word(*__pre)
|
else if (_M_at_end())
|
||||||
&& !(_M_flags & regex_constants::match_not_eow);
|
__ans = _M_is_word(*__pre)
|
||||||
else
|
&& !(_M_flags & regex_constants::match_not_eow);
|
||||||
__ans = _M_is_word(*_M_current)
|
else
|
||||||
!= _M_is_word(*__pre);
|
__ans = _M_is_word(*_M_current)
|
||||||
|
!= _M_is_word(*__pre);
|
||||||
|
}
|
||||||
return __ans;
|
return __ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
_Scanner<_FwdIter>::
|
_Scanner<_FwdIter>::
|
||||||
_Scanner(_FwdIter __begin, _FwdIter __end,
|
_Scanner(_FwdIter __begin, _FwdIter __end,
|
||||||
_FlagT __flags, std::locale __loc)
|
_FlagT __flags, std::locale __loc)
|
||||||
: _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
|
: _M_state(_S_state_normal), _M_current(__begin), _M_end(__end),
|
||||||
_M_ctype(std::use_facet<_CtypeT>(__loc)), _M_state(_S_state_normal),
|
_M_flags(__flags),
|
||||||
|
_M_ctype(std::use_facet<_CtypeT>(__loc)),
|
||||||
_M_at_bracket_start(false),
|
_M_at_bracket_start(false),
|
||||||
_M_token_map
|
_M_token_map
|
||||||
{
|
{
|
||||||
|
|
@ -94,9 +95,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
{'t', '\t'},
|
{'t', '\t'},
|
||||||
{'v', '\v'},
|
{'v', '\v'},
|
||||||
},
|
},
|
||||||
_M_escape_map(_M_is_ecma()
|
|
||||||
? _M_ecma_escape_map
|
|
||||||
: _M_awk_escape_map),
|
|
||||||
_M_ecma_spec_char
|
_M_ecma_spec_char
|
||||||
{
|
{
|
||||||
'^',
|
'^',
|
||||||
|
|
@ -138,14 +136,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
'^',
|
'^',
|
||||||
'$',
|
'$',
|
||||||
},
|
},
|
||||||
_M_eat_escape(_M_is_ecma()
|
_M_escape_map(_M_is_ecma()
|
||||||
? &_Scanner::_M_eat_escape_ecma
|
? _M_ecma_escape_map
|
||||||
: &_Scanner::_M_eat_escape_posix),
|
: _M_awk_escape_map),
|
||||||
_M_spec_char(_M_is_ecma()
|
_M_spec_char(_M_is_ecma()
|
||||||
? _M_ecma_spec_char
|
? _M_ecma_spec_char
|
||||||
: _M_is_basic()
|
: _M_is_basic()
|
||||||
? _M_basic_spec_char
|
? _M_basic_spec_char
|
||||||
: _M_extended_spec_char)
|
: _M_extended_spec_char),
|
||||||
|
_M_eat_escape(_M_is_ecma()
|
||||||
|
? &_Scanner::_M_eat_escape_ecma
|
||||||
|
: &_Scanner::_M_eat_escape_posix)
|
||||||
{ _M_advance(); }
|
{ _M_advance(); }
|
||||||
|
|
||||||
template<typename _FwdIter>
|
template<typename _FwdIter>
|
||||||
|
|
@ -243,9 +244,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
_M_state = _S_state_in_brace;
|
_M_state = _S_state_in_brace;
|
||||||
_M_token = _S_token_interval_begin;
|
_M_token = _S_token_interval_begin;
|
||||||
}
|
}
|
||||||
else if (_M_spec_char.count(__c)
|
else if ((_M_spec_char.count(__c)
|
||||||
&& __c != ']'
|
&& __c != ']'
|
||||||
&& __c != '}'
|
&& __c != '}')
|
||||||
|| (_M_is_grep() && __c == '\n'))
|
|| (_M_is_grep() && __c == '\n'))
|
||||||
_M_token = _M_token_map.at(__c);
|
_M_token = _M_token_map.at(__c);
|
||||||
else
|
else
|
||||||
|
|
@ -515,10 +516,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
|| *_M_current++ != __ch
|
|| *_M_current++ != __ch
|
||||||
|| _M_current == _M_end // skip __ch
|
|| _M_current == _M_end // skip __ch
|
||||||
|| *_M_current++ != ']') // skip ']'
|
|| *_M_current++ != ']') // skip ']'
|
||||||
if (__ch == ':')
|
{
|
||||||
__throw_regex_error(regex_constants::error_ctype);
|
if (__ch == ':')
|
||||||
else
|
__throw_regex_error(regex_constants::error_ctype);
|
||||||
__throw_regex_error(regex_constants::error_collate);
|
else
|
||||||
|
__throw_regex_error(regex_constants::error_collate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _GLIBCXX_DEBUG
|
#ifdef _GLIBCXX_DEBUG
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue