aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2013-10-17 20:46:50 +0000
committerTim Shen <timshen@gcc.gnu.org>2013-10-17 20:46:50 +0000
commitab1c993b94cc09cf569f75c34c943f6e695a0ec3 (patch)
tree77c6c62f2454b98891ae2a05692b8bb9114f3b8d /libstdc++-v3
parent358e1993d0b76b2643aee7565e2c5aef38a369ae (diff)
downloadgcc-ab1c993b94cc09cf569f75c34c943f6e695a0ec3.zip
gcc-ab1c993b94cc09cf569f75c34c943f6e695a0ec3.tar.gz
gcc-ab1c993b94cc09cf569f75c34c943f6e695a0ec3.tar.bz2
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
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog19
-rw-r--r--libstdc++-v3/include/bits/regex.h8
-rw-r--r--libstdc++-v3/include/bits/regex.tcc53
-rw-r--r--libstdc++-v3/include/bits/regex_automaton.h2
-rw-r--r--libstdc++-v3/include/bits/regex_compiler.h6
-rw-r--r--libstdc++-v3/include/bits/regex_compiler.tcc3
-rw-r--r--libstdc++-v3/include/bits/regex_executor.h2
-rw-r--r--libstdc++-v3/include/bits/regex_executor.tcc38
-rw-r--r--libstdc++-v3/include/bits/regex_scanner.tcc35
9 files changed, 94 insertions, 72 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 80abfa8..5ae46af 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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>
* include/bits/regex.h (regex_token_iterator<>::regex_token_iterator):
diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 172ea83..5d1a8f4 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -2514,7 +2514,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
* 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)
{ }
@@ -2601,7 +2601,7 @@ _GLIBCXX_END_NAMESPACE_VERSION
*/
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)
@@ -2679,10 +2679,10 @@ _GLIBCXX_END_NAMESPACE_VERSION
{ 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;
diff --git a/libstdc++-v3/include/bits/regex.tcc b/libstdc++-v3/include/bits/regex.tcc
index 0576422..b3b5314 100644
--- a/libstdc++-v3/include/bits/regex.tcc
+++ b/libstdc++-v3/include/bits/regex.tcc
@@ -61,14 +61,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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)
@@ -540,26 +534,29 @@ _GLIBCXX_END_NAMESPACE_VERSION
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))
{
diff --git a/libstdc++-v3/include/bits/regex_automaton.h b/libstdc++-v3/include/bits/regex_automaton.h
index 35cfc1b..cb94499 100644
--- a/libstdc++-v3/include/bits/regex_automaton.h
+++ b/libstdc++-v3/include/bits/regex_automaton.h
@@ -138,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_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
diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h
index 297fe3f..7e4e6ad 100644
--- a/libstdc++-v3/include/bits/regex_compiler.h
+++ b/libstdc++-v3/include/bits/regex_compiler.h
@@ -156,7 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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
@@ -189,8 +189,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_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
diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc
index 52386ce..e3764b8 100644
--- a/libstdc++-v3/include/bits/regex_compiler.tcc
+++ b/libstdc++-v3/include/bits/regex_compiler.tcc
@@ -73,8 +73,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
? __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());
@@ -318,7 +318,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
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))
diff --git a/libstdc++-v3/include/bits/regex_executor.h b/libstdc++-v3/include/bits/regex_executor.h
index 23b5d01..018b649 100644
--- a/libstdc++-v3/include/bits/regex_executor.h
+++ b/libstdc++-v3/include/bits/regex_executor.h
@@ -74,8 +74,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_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
diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc
index 59b082e..b875573 100644
--- a/libstdc++-v3/include/bits/regex_executor.tcc
+++ b/libstdc++-v3/include/bits/regex_executor.tcc
@@ -145,15 +145,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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:
@@ -353,15 +355,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
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;
}
diff --git a/libstdc++-v3/include/bits/regex_scanner.tcc b/libstdc++-v3/include/bits/regex_scanner.tcc
index fc82738..21d1e91 100644
--- a/libstdc++-v3/include/bits/regex_scanner.tcc
+++ b/libstdc++-v3/include/bits/regex_scanner.tcc
@@ -56,8 +56,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_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
{
@@ -94,9 +95,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{'t', '\t'},
{'v', '\v'},
},
- _M_escape_map(_M_is_ecma()
- ? _M_ecma_escape_map
- : _M_awk_escape_map),
_M_ecma_spec_char
{
'^',
@@ -138,14 +136,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
'^',
'$',
},
- _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>
@@ -243,9 +244,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_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
@@ -515,10 +516,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|| *_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