From patchwork Fri Nov 8 14:30:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 289846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 60F712C00DE for ; Sat, 9 Nov 2013 01:31:19 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=TcHTf8oJLdJpQZczPGD5UWESqcSO/frc75ZYdTps6C1 mN+0TJSq8LnsJ1DkUHo4H3q7X56PUnaiGixt4RYzb9suOcI+3y+vP5MGRd2wvHD/ StRa/ytr1uYKduhJRBekwkEAqEynAJAhtlCX742lmESe9ewI5uG0qpKdwI35VSAU = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=/Zfh26mZFqdp9tb14jshncnbAPA=; b=VeFd98rerJJblEJZ9 pdL+f9ZJ+RGUfyzikpujSwYBgLfK6cEi/F4+lWBGD2lvt8SM0onJOhsxnfWWQLyd 7gBOKD8GCXnKgpYL6tDeysaQYsk5RQfeErtG1R+mInqAVe802n8wdFm+Tta3ltKO 4Bsv2rcv5nJ1iPmrYb0eGsZzrI= Received: (qmail 10554 invoked by alias); 8 Nov 2013 14:31:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 10536 invoked by uid 89); 8 Nov 2013 14:31:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, RDNS_NONE, SPAM_SUBJECT, SPF_PASS autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-lb0-f182.google.com Received: from Unknown (HELO mail-lb0-f182.google.com) (209.85.217.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 08 Nov 2013 14:31:02 +0000 Received: by mail-lb0-f182.google.com with SMTP id w6so1536550lbh.13 for ; Fri, 08 Nov 2013 06:30:52 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.112.210.66 with SMTP id ms2mr92591lbc.51.1383921052528; Fri, 08 Nov 2013 06:30:52 -0800 (PST) Received: by 10.112.173.195 with HTTP; Fri, 8 Nov 2013 06:30:52 -0800 (PST) Date: Fri, 8 Nov 2013 14:30:52 +0000 Message-ID: Subject: [patch 1/4] std::regex refactoring From: Jonathan Wakely To: "libstdc++" , gcc-patches Cc: Tim Shen , "Stephen M. Webb" This creates new base classes for the parts of _State and _NFA which are not dependent on template parameters, and replaces some copies with moves. 2013-11-08 Jonathan Wakely * include/bits/regex_automaton.h (__detail::_State): Split non-dependent parts into new _State_base. (__detail::_NFA): Likewise for _NFA_base. Use std::move() to avoid copies when inserting _MatcherT and _StateT objects. * include/bits/regex_automaton.tcc: Move member definitions to base class. Qualify dependent names. * include/bits/regex_compiler.h (__detail::_Compiler::_M_get_nfa): Make non-const and use std::move to avoid copying. * include/bits/regex_compiler.tcc: Likewise. * include/bits/regex_executor.h (__detail::_Executor::_M_is_word): Use array, so past-the-end iterator is valid. Tested x86_64-linux, committed to trunk. commit 3404a066d12f458e2b441798dbd70dfa21ef537d Author: Jonathan Wakely Date: Wed Nov 6 09:09:35 2013 +0000 * include/bits/regex_automaton.h (__detail::_State): Split non-dependent parts into new _State_base. (__detail::_NFA): Likewise for _NFA_base. Use std::move() to avoid copies when inserting _MatcherT and _StateT objects. * include/bits/regex_automaton.tcc: Move member definitions to base class. Qualify dependent names. * include/bits/regex_compiler.h (__detail::_Compiler::_M_get_nfa): Make non-const and use std::move to avoid copying. * include/bits/regex_compiler.tcc: Likewise. * include/bits/regex_executor.h (__detail::_Executor::_M_is_word): Use array, so past-the-end iterator is valid. diff --git a/libstdc++-v3/include/bits/regex_automaton.h b/libstdc++-v3/include/bits/regex_automaton.h index e630512..ded3716 100644 --- a/libstdc++-v3/include/bits/regex_automaton.h +++ b/libstdc++-v3/include/bits/regex_automaton.h @@ -65,81 +65,114 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _S_opcode_accept, }; - template - class _State + struct _State_base + { + _Opcode _M_opcode; // type of outgoing transition + _StateIdT _M_next; // outgoing transition + union // Since they are mutually exclusive. { - public: - typedef _Matcher<_CharT> _MatcherT; - - _Opcode _M_opcode; // type of outgoing transition - _StateIdT _M_next; // outgoing transition - union // Since they are mutually exclusive. + size_t _M_subexpr; // for _S_opcode_subexpr_* + size_t _M_backref_index; // for _S_opcode_backref + struct { - size_t _M_subexpr; // for _S_opcode_subexpr_* - size_t _M_backref_index; // for _S_opcode_backref - struct - { - // for _S_opcode_alternative. - _StateIdT _M_quant_index; - // for _S_opcode_alternative or _S_opcode_subexpr_lookahead - _StateIdT _M_alt; - // for _S_opcode_word_boundary or _S_opcode_subexpr_lookahead or - // quantifiers(ungreedy if set true) - bool _M_neg; - }; + // for _S_opcode_alternative. + _StateIdT _M_quant_index; + // for _S_opcode_alternative or _S_opcode_subexpr_lookahead + _StateIdT _M_alt; + // for _S_opcode_word_boundary or _S_opcode_subexpr_lookahead or + // quantifiers (ungreedy if set true) + bool _M_neg; }; - _MatcherT _M_matches; // for _S_opcode_match + }; - explicit _State(_Opcode __opcode) - : _M_opcode(__opcode), _M_next(_S_invalid_state_id) - { } + explicit _State_base(_Opcode __opcode) + : _M_opcode(__opcode), _M_next(_S_invalid_state_id) + { } + + protected: + ~_State_base() = default; + public: #ifdef _GLIBCXX_DEBUG - std::ostream& - _M_print(std::ostream& ostr) const; + std::ostream& + _M_print(std::ostream& ostr) const; - // Prints graphviz dot commands for state. - std::ostream& - _M_dot(std::ostream& __ostr, _StateIdT __id) const; + // Prints graphviz dot commands for state. + std::ostream& + _M_dot(std::ostream& __ostr, _StateIdT __id) const; #endif - }; + }; template - class _NFA - : public std::vector<_State<_CharT, _TraitsT>> + struct _State : _State_base { - public: - typedef _State<_CharT, _TraitsT> _StateT; - typedef const _Matcher<_CharT>& _MatcherT; - typedef size_t _SizeT; - typedef regex_constants::syntax_option_type _FlagT; - - _NFA(_FlagT __f) - : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0), - _M_quant_count(0), _M_has_backref(false) - { } + typedef _Matcher<_CharT> _MatcherT; - _FlagT - _M_options() const - { return _M_flags; } + _MatcherT _M_matches; // for _S_opcode_match - _StateIdT - _M_start() const - { return _M_start_state; } + explicit _State(_Opcode __opcode) : _State_base(__opcode) { } + }; - const _StateSet& - _M_final_states() const - { return _M_accepting_states; } + struct _NFA_base + { + typedef size_t _SizeT; + typedef regex_constants::syntax_option_type _FlagT; + + explicit + _NFA_base(_FlagT __f) + : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0), + _M_quant_count(0), _M_has_backref(false) + { } + + _NFA_base(_NFA_base&&) = default; + + protected: + ~_NFA_base() = default; + + public: + _FlagT + _M_options() const + { return _M_flags; } + + _StateIdT + _M_start() const + { return _M_start_state; } + + const _StateSet& + _M_final_states() const + { return _M_accepting_states; } + + _SizeT + _M_sub_count() const + { return _M_subexpr_count; } + + std::vector _M_paren_stack; + _StateSet _M_accepting_states; + _FlagT _M_flags; + _StateIdT _M_start_state; + _SizeT _M_subexpr_count; + _SizeT _M_quant_count; + bool _M_has_backref; + }; + + template + struct _NFA + : _NFA_base, std::vector<_State<_CharT, _TraitsT>> + { + typedef _State<_CharT, _TraitsT> _StateT; + typedef _Matcher<_CharT> _MatcherT; + + using _NFA_base::_NFA_base; - _SizeT - _M_sub_count() const - { return _M_subexpr_count; } + // for performance reasons _NFA objects should only be moved not copied + _NFA(const _NFA&) = delete; + _NFA(_NFA&&) = default; _StateIdT _M_insert_accept() { auto __ret = _M_insert_state(_StateT(_S_opcode_accept)); - _M_accepting_states.insert(__ret); + this->_M_accepting_states.insert(__ret); return __ret; } @@ -149,38 +182,38 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _StateT __tmp(_S_opcode_alternative); // It labels every quantifier to make greedy comparison easier in BFS // approach. - __tmp._M_quant_index = _M_quant_count++; + __tmp._M_quant_index = this->_M_quant_count++; __tmp._M_next = __next; __tmp._M_alt = __alt; __tmp._M_neg = __neg; - return _M_insert_state(__tmp); + return _M_insert_state(std::move(__tmp)); } _StateIdT _M_insert_matcher(_MatcherT __m) { _StateT __tmp(_S_opcode_match); - __tmp._M_matches = __m; - return _M_insert_state(__tmp); + __tmp._M_matches = std::move(__m); + return _M_insert_state(std::move(__tmp)); } _StateIdT _M_insert_subexpr_begin() { - auto __id = _M_subexpr_count++; - _M_paren_stack.push_back(__id); + auto __id = this->_M_subexpr_count++; + this->_M_paren_stack.push_back(__id); _StateT __tmp(_S_opcode_subexpr_begin); __tmp._M_subexpr = __id; - return _M_insert_state(__tmp); + return _M_insert_state(std::move(__tmp)); } _StateIdT _M_insert_subexpr_end() { _StateT __tmp(_S_opcode_subexpr_end); - __tmp._M_subexpr = _M_paren_stack.back(); - _M_paren_stack.pop_back(); - return _M_insert_state(__tmp); + __tmp._M_subexpr = this->_M_paren_stack.back(); + this->_M_paren_stack.pop_back(); + return _M_insert_state(std::move(__tmp)); } _StateIdT @@ -199,7 +232,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { _StateT __tmp(_S_opcode_word_boundary); __tmp._M_neg = __neg; - return _M_insert_state(__tmp); + return _M_insert_state(std::move(__tmp)); } _StateIdT @@ -208,7 +241,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _StateT __tmp(_S_opcode_subexpr_lookahead); __tmp._M_alt = __alt; __tmp._M_neg = __neg; - return _M_insert_state(__tmp); + return _M_insert_state(std::move(__tmp)); } _StateIdT @@ -218,7 +251,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _StateIdT _M_insert_state(_StateT __s) { - this->push_back(__s); + this->push_back(std::move(__s)); return this->size()-1; } @@ -230,14 +263,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION std::ostream& _M_dot(std::ostream& __ostr) const; #endif - - std::vector _M_paren_stack; - _StateSet _M_accepting_states; - _FlagT _M_flags; - _StateIdT _M_start_state; - _SizeT _M_subexpr_count; - _SizeT _M_quant_count; - bool _M_has_backref; }; /// Describes a sequence of one or more %_State, its current start @@ -251,7 +276,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: _StateSeq(_RegexT& __nfa, _StateIdT __s) - : _StateSeq(__nfa, __s, __s) + : _M_nfa(__nfa), _M_start(__s), _M_end(__s) { } _StateSeq(_RegexT& __nfa, _StateIdT __s, _StateIdT __end) diff --git a/libstdc++-v3/include/bits/regex_automaton.tcc b/libstdc++-v3/include/bits/regex_automaton.tcc index 258d22d..0c25c63 100644 --- a/libstdc++-v3/include/bits/regex_automaton.tcc +++ b/libstdc++-v3/include/bits/regex_automaton.tcc @@ -35,118 +35,116 @@ namespace __detail _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_DEBUG - template - std::ostream& _State<_CharT, _TraitsT>:: - _M_print(std::ostream& ostr) const + std::ostream& + _State_base::_M_print(std::ostream& ostr) const + { + switch (_M_opcode) { - switch (_M_opcode) - { - case _S_opcode_alternative: - ostr << "alt next=" << _M_next << " alt=" << _M_alt; - break; - case _S_opcode_subexpr_begin: - ostr << "subexpr begin next=" << _M_next << " index=" << _M_subexpr; - break; - case _S_opcode_subexpr_end: - ostr << "subexpr end next=" << _M_next << " index=" << _M_subexpr; - break; - case _S_opcode_backref: - ostr << "backref next=" << _M_next << " index=" << _M_backref_index; - break; - case _S_opcode_match: - ostr << "match next=" << _M_next; - break; - case _S_opcode_accept: - ostr << "accept next=" << _M_next; - break; - default: - ostr << "unknown next=" << _M_next; - break; - } - return ostr; + case _S_opcode_alternative: + ostr << "alt next=" << _M_next << " alt=" << _M_alt; + break; + case _S_opcode_subexpr_begin: + ostr << "subexpr begin next=" << _M_next << " index=" << _M_subexpr; + break; + case _S_opcode_subexpr_end: + ostr << "subexpr end next=" << _M_next << " index=" << _M_subexpr; + break; + case _S_opcode_backref: + ostr << "backref next=" << _M_next << " index=" << _M_backref_index; + break; + case _S_opcode_match: + ostr << "match next=" << _M_next; + break; + case _S_opcode_accept: + ostr << "accept next=" << _M_next; + break; + default: + ostr << "unknown next=" << _M_next; + break; } + return ostr; + } // Prints graphviz dot commands for state. - template - std::ostream& _State<_CharT, _TraitsT>:: - _M_dot(std::ostream& __ostr, _StateIdT __id) const + std::ostream& + _State_base::_M_dot(std::ostream& __ostr, _StateIdT __id) const + { + switch (_M_opcode) { - switch (_M_opcode) - { - case _S_opcode_alternative: - __ostr << __id << " [label=\"" << __id << "\\nALT\"];\n" - << __id << " -> " << _M_next - << " [label=\"epsilon\", tailport=\"s\"];\n" - << __id << " -> " << _M_alt - << " [label=\"epsilon\", tailport=\"n\"];\n"; - break; - case _S_opcode_backref: - __ostr << __id << " [label=\"" << __id << "\\nBACKREF " - << _M_subexpr << "\"];\n" - << __id << " -> " << _M_next << " [label=\"\"];\n"; - break; - case _S_opcode_line_begin_assertion: - __ostr << __id << " [label=\"" << __id << "\\nLINE_BEGIN \"];\n" - << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; - break; - case _S_opcode_line_end_assertion: - __ostr << __id << " [label=\"" << __id << "\\nLINE_END \"];\n" - << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; - break; - case _S_opcode_word_boundary: - __ostr << __id << " [label=\"" << __id << "\\nWORD_BOUNDRY " - << _M_neg << "\"];\n" - << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; - break; - case _S_opcode_subexpr_lookahead: - __ostr << __id << " [label=\"" << __id << "\\nLOOK_AHEAD\"];\n" - << __id << " -> " << _M_next - << " [label=\"epsilon\", tailport=\"s\"];\n" - << __id << " -> " << _M_alt - << " [label=\"\", tailport=\"n\"];\n"; - break; - case _S_opcode_subexpr_begin: - __ostr << __id << " [label=\"" << __id << "\\nSBEGIN " - << _M_subexpr << "\"];\n" - << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; - break; - case _S_opcode_subexpr_end: - __ostr << __id << " [label=\"" << __id << "\\nSEND " - << _M_subexpr << "\"];\n" - << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; - break; - case _S_opcode_dummy: - break; - case _S_opcode_match: - __ostr << __id << " [label=\"" << __id << "\\nMATCH\"];\n" - << __id << " -> " << _M_next << " [label=\"\"];\n"; - break; - case _S_opcode_accept: - __ostr << __id << " [label=\"" << __id << "\\nACC\"];\n" ; - break; - default: - _GLIBCXX_DEBUG_ASSERT(false); - break; - } - return __ostr; + case _S_opcode_alternative: + __ostr << __id << " [label=\"" << __id << "\\nALT\"];\n" + << __id << " -> " << _M_next + << " [label=\"epsilon\", tailport=\"s\"];\n" + << __id << " -> " << _M_alt + << " [label=\"epsilon\", tailport=\"n\"];\n"; + break; + case _S_opcode_backref: + __ostr << __id << " [label=\"" << __id << "\\nBACKREF " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"\"];\n"; + break; + case _S_opcode_line_begin_assertion: + __ostr << __id << " [label=\"" << __id << "\\nLINE_BEGIN \"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_line_end_assertion: + __ostr << __id << " [label=\"" << __id << "\\nLINE_END \"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_word_boundary: + __ostr << __id << " [label=\"" << __id << "\\nWORD_BOUNDRY " + << _M_neg << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_subexpr_lookahead: + __ostr << __id << " [label=\"" << __id << "\\nLOOK_AHEAD\"];\n" + << __id << " -> " << _M_next + << " [label=\"epsilon\", tailport=\"s\"];\n" + << __id << " -> " << _M_alt + << " [label=\"\", tailport=\"n\"];\n"; + break; + case _S_opcode_subexpr_begin: + __ostr << __id << " [label=\"" << __id << "\\nSBEGIN " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_subexpr_end: + __ostr << __id << " [label=\"" << __id << "\\nSEND " + << _M_subexpr << "\"];\n" + << __id << " -> " << _M_next << " [label=\"epsilon\"];\n"; + break; + case _S_opcode_dummy: + break; + case _S_opcode_match: + __ostr << __id << " [label=\"" << __id << "\\nMATCH\"];\n" + << __id << " -> " << _M_next << " [label=\"\"];\n"; + break; + case _S_opcode_accept: + __ostr << __id << " [label=\"" << __id << "\\nACC\"];\n" ; + break; + default: + _GLIBCXX_DEBUG_ASSERT(false); + break; } + return __ostr; + } template - std::ostream& _NFA<_CharT, _TraitsT>:: - _M_dot(std::ostream& __ostr) const + std::ostream& + _NFA<_CharT, _TraitsT>::_M_dot(std::ostream& __ostr) const { __ostr << "digraph _Nfa {\n" - << " rankdir=LR;\n"; + " rankdir=LR;\n"; for (size_t __i = 0; __i < this->size(); ++__i) - { this->at(__i)._M_dot(__ostr, __i); } + (*this)[__i]._M_dot(__ostr, __i); __ostr << "}\n"; return __ostr; } #endif template - _StateIdT _NFA<_CharT, _TraitsT>:: - _M_insert_backref(size_t __index) + _StateIdT + _NFA<_CharT, _TraitsT>::_M_insert_backref(size_t __index) { // To figure out whether a backref is valid, a stack is used to store // unfinished sub-expressions. For example, when parsing @@ -157,18 +155,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // time, "\\2" is valid, but "\\1" and "\\3" are not. if (__index >= _M_subexpr_count) __throw_regex_error(regex_constants::error_backref); - for (auto __it : _M_paren_stack) + for (auto __it : this->_M_paren_stack) if (__index == __it) __throw_regex_error(regex_constants::error_backref); - _M_has_backref = true; + this->_M_has_backref = true; _StateT __tmp(_S_opcode_backref); __tmp._M_backref_index = __index; - return _M_insert_state(__tmp); + return _M_insert_state(std::move(__tmp)); } template - void _NFA<_CharT, _TraitsT>:: - _M_eliminate_dummy() + void + _NFA<_CharT, _TraitsT>::_M_eliminate_dummy() { for (auto& __it : *this) { @@ -185,8 +183,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Just apply DFS on the sequence and re-link their links. template - _StateSeq<_CharT, _TraitsT> _StateSeq<_CharT, _TraitsT>:: - _M_clone() + _StateSeq<_CharT, _TraitsT> + _StateSeq<_CharT, _TraitsT>::_M_clone() { std::map<_StateIdT, _StateIdT> __m; std::stack<_StateIdT> __stack; diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h index 7e4e6ad..98141a7 100644 --- a/libstdc++-v3/include/bits/regex_compiler.h +++ b/libstdc++-v3/include/bits/regex_compiler.h @@ -55,8 +55,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION const _TraitsT& __traits, _FlagT __flags); std::shared_ptr<_RegexT> - _M_get_nfa() const - { return make_shared<_RegexT>(_M_nfa); } + _M_get_nfa() + { return make_shared<_RegexT>(std::move(_M_nfa)); } private: typedef _Scanner<_FwdIter> _ScannerT; diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc index e3764b8..58ef0f0 100644 --- a/libstdc++-v3/include/bits/regex_compiler.tcc +++ b/libstdc++-v3/include/bits/regex_compiler.tcc @@ -147,11 +147,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_assertion() { if (_M_match_token(_ScannerT::_S_token_line_begin)) - _M_stack.push(_StateSeqT(_M_nfa, _M_nfa. - _M_insert_line_begin())); + _M_stack.push(_StateSeqT(_M_nfa, _M_nfa._M_insert_line_begin())); else if (_M_match_token(_ScannerT::_S_token_line_end)) - _M_stack.push(_StateSeqT(_M_nfa, _M_nfa. - _M_insert_line_end())); + _M_stack.push(_StateSeqT(_M_nfa, _M_nfa._M_insert_line_end())); else if (_M_match_token(_ScannerT::_S_token_word_bound)) // _M_value[0] == 'n' means it's negtive, say "not word boundary". _M_stack.push(_StateSeqT(_M_nfa, _M_nfa. @@ -305,7 +303,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _M_traits, _M_flags); __matcher._M_add_character_class(_M_value); _M_stack.push(_StateSeqT(_M_nfa, - _M_nfa._M_insert_matcher(__matcher))); + _M_nfa._M_insert_matcher(std::move(__matcher)))); } else if (_M_match_token(_ScannerT::_S_token_subexpr_no_group_begin)) { @@ -343,7 +341,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _BMatcherT __matcher(__neg, _M_traits, _M_flags); while (!_M_match_token(_ScannerT::_S_token_bracket_end)) _M_expression_term(__matcher); - _M_stack.push(_StateSeqT(_M_nfa, _M_nfa._M_insert_matcher(__matcher))); + _M_stack.push(_StateSeqT(_M_nfa, + _M_nfa._M_insert_matcher(std::move(__matcher)))); return true; } @@ -432,8 +431,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template - bool _BracketMatcher<_CharT, _TraitsT>:: - operator()(_CharT __ch) const + bool + _BracketMatcher<_CharT, _TraitsT>::operator()(_CharT __ch) const { bool __ret = false; if (_M_traits.isctype(__ch, _M_class_set) diff --git a/libstdc++-v3/include/bits/regex_executor.h b/libstdc++-v3/include/bits/regex_executor.h index 57b3108..f08f292 100644 --- a/libstdc++-v3/include/bits/regex_executor.h +++ b/libstdc++-v3/include/bits/regex_executor.h @@ -53,7 +53,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template + bool __dfs_mode> class _Executor { public: @@ -117,9 +117,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool _M_is_word(_CharT __ch) const { - static const _CharT __s = 'w'; + static const _CharT __s[2] = { 'w' }; return _M_re._M_traits.isctype - (__ch, _M_re._M_traits.lookup_classname(&__s, &__s+1)); + (__ch, _M_re._M_traits.lookup_classname(__s, __s+1)); } bool