* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203798
138bc75d-0d04-0410-961f-
82ee72b054a4
+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>
* include/bits/regex.h (regex_token_iterator<>::regex_token_iterator):
* iterator of the same type.
*/
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)
{ }
*/
regex_token_iterator(const regex_token_iterator& __rhs)
: _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)
{
if (__rhs._M_result == &__rhs._M_suffix)
{ return _M_result == nullptr; }
_Position _M_position;
- const value_type* _M_result;
+ std::vector<int> _M_subs;
value_type _M_suffix;
std::size_t _M_n;
- std::vector<int> _M_subs;
+ const value_type* _M_result;
// Show whether _M_subs contains -1
bool _M_has_m1;
for (auto& __it : __res)
__it.matched = false;
- typedef std::unique_ptr<_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
- _ExecutorPtr;
- 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);
+ auto __executor = __get_executor<_BiIter, _Alloc, _CharT, _TraitsT,
+ __policy>(__s, __e, __res, __re, __flags);
bool __ret;
if (__match_mode)
auto __start = _M_match[0].second;
auto __prefix_first = _M_match[0].second;
if (_M_match[0].first == _M_match[0].second)
- if (__start == _M_end)
- {
- _M_match = value_type();
- return *this;
- }
- else
- {
- if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags
- | regex_constants::match_not_null
- | regex_constants::match_continuous))
- {
- _GLIBCXX_DEBUG_ASSERT(_M_match[0].matched);
- _M_match.at(_M_match.size()).first = __prefix_first;
- _M_match._M_in_iterator = true;
- _M_match._M_begin = _M_begin;
- return *this;
- }
- else
- ++__start;
- }
+ {
+ if (__start == _M_end)
+ {
+ _M_match = value_type();
+ return *this;
+ }
+ else
+ {
+ if (regex_search(__start, _M_end, _M_match, *_M_pregex,
+ _M_flags
+ | regex_constants::match_not_null
+ | regex_constants::match_continuous))
+ {
+ _GLIBCXX_DEBUG_ASSERT(_M_match[0].matched);
+ _M_match.at(_M_match.size()).first = __prefix_first;
+ _M_match._M_in_iterator = true;
+ _M_match._M_begin = _M_begin;
+ return *this;
+ }
+ else
+ ++__start;
+ }
+ }
_M_flags |= regex_constants::match_prev_avail;
if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags))
{
_NFA(_FlagT __f)
: _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
explicit
_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
_BracketMatcher(bool __is_non_matching,
const _TraitsT& __traits,
_FlagT __flags)
- : _M_is_non_matching(__is_non_matching), _M_traits(__traits),
- _M_flags(__flags), _M_class_set(0)
+ : _M_traits(__traits), _M_class_set(0), _M_flags(__flags),
+ _M_is_non_matching(__is_non_matching)
{ }
bool
? __flags
: __flags | regex_constants::ECMAScript),
_M_traits(__traits),
- _M_scanner(__b, __e, _M_flags, _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)
{
_StateSeqT __r(_M_nfa, _M_nfa._M_start());
}
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());
this->_M_disjunction();
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
_FlagT __flags)
: _M_begin(__begin),
_M_end(__end),
- _M_results(__results),
_M_re(__re),
+ _M_results(__results),
_M_flags((__flags & regex_constants::match_prev_avail)
? (__flags
& ~regex_constants::match_not_bol
if (this->_M_re._M_traits.transform(__submatch.first,
__submatch.second)
== this->_M_re._M_traits.transform(__current, __last))
- if (__last != __current)
- {
- auto __backup = __current;
- __current = __last;
+ {
+ if (__last != __current)
+ {
+ auto __backup = __current;
+ __current = __last;
+ __ret = _M_dfs(__state._M_next);
+ __current = __backup;
+ }
+ else
__ret = _M_dfs(__state._M_next);
- __current = __backup;
- }
- else
- __ret = _M_dfs(__state._M_next);
+ }
}
break;
case _S_opcode_accept:
auto __pre = _M_current;
--__pre;
if (!(_M_at_begin() && _M_at_end()))
- if (_M_at_begin())
- __ans = _M_is_word(*_M_current)
- && !(_M_flags & regex_constants::match_not_bow);
- else if (_M_at_end())
- __ans = _M_is_word(*__pre)
- && !(_M_flags & regex_constants::match_not_eow);
- else
- __ans = _M_is_word(*_M_current)
- != _M_is_word(*__pre);
+ {
+ if (_M_at_begin())
+ __ans = _M_is_word(*_M_current)
+ && !(_M_flags & regex_constants::match_not_bow);
+ else if (_M_at_end())
+ __ans = _M_is_word(*__pre)
+ && !(_M_flags & regex_constants::match_not_eow);
+ else
+ __ans = _M_is_word(*_M_current)
+ != _M_is_word(*__pre);
+ }
return __ans;
}
_Scanner<_FwdIter>::
_Scanner(_FwdIter __begin, _FwdIter __end,
_FlagT __flags, std::locale __loc)
- : _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
- _M_ctype(std::use_facet<_CtypeT>(__loc)), _M_state(_S_state_normal),
+ : _M_state(_S_state_normal), _M_current(__begin), _M_end(__end),
+ _M_flags(__flags),
+ _M_ctype(std::use_facet<_CtypeT>(__loc)),
_M_at_bracket_start(false),
_M_token_map
{
{'t', '\t'},
{'v', '\v'},
},
- _M_escape_map(_M_is_ecma()
- ? _M_ecma_escape_map
- : _M_awk_escape_map),
_M_ecma_spec_char
{
'^',
'^',
'$',
},
- _M_eat_escape(_M_is_ecma()
- ? &_Scanner::_M_eat_escape_ecma
- : &_Scanner::_M_eat_escape_posix),
+ _M_escape_map(_M_is_ecma()
+ ? _M_ecma_escape_map
+ : _M_awk_escape_map),
_M_spec_char(_M_is_ecma()
? _M_ecma_spec_char
: _M_is_basic()
? _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(); }
template<typename _FwdIter>
_M_state = _S_state_in_brace;
_M_token = _S_token_interval_begin;
}
- else if (_M_spec_char.count(__c)
- && __c != ']'
- && __c != '}'
+ else if ((_M_spec_char.count(__c)
+ && __c != ']'
+ && __c != '}')
|| (_M_is_grep() && __c == '\n'))
_M_token = _M_token_map.at(__c);
else
|| *_M_current++ != __ch
|| _M_current == _M_end // skip __ch
|| *_M_current++ != ']') // skip ']'
- if (__ch == ':')
- __throw_regex_error(regex_constants::error_ctype);
- else
- __throw_regex_error(regex_constants::error_collate);
+ {
+ if (__ch == ':')
+ __throw_regex_error(regex_constants::error_ctype);
+ else
+ __throw_regex_error(regex_constants::error_collate);
+ }
}
#ifdef _GLIBCXX_DEBUG