commit 82f3e9fa7d16a677bb9ebc6bc3da12c1209c2df5
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sun Jun 29 17:58:59 2014 +0100
* include/bits/regex_scanner.h (_ScannerBase): Replace member data
with static member functions.
* include/bits/regex_scanner.tcc (_ScannerBase): Likewise.
@@ -1,4 +1,4 @@
-// class template regex -*- C++ -*-
+// Regex implementation -*- C++ -*-
// Copyright (C) 2013-2014 Free Software Foundation, Inc.
//
@@ -92,13 +92,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _M_state(_S_state_normal),
_M_flags(__flags),
_M_escape_tbl(_M_is_ecma()
- ? _M_ecma_escape_tbl
- : _M_awk_escape_tbl),
+ ? _S_ecma_escape_tbl()
+ : _S_awk_escape_tbl()),
_M_spec_char(_M_is_ecma()
- ? _M_ecma_spec_char
+ ? _S_ecma_spec_char()
: _M_is_basic()
- ? _M_basic_spec_char
- : _M_extended_spec_char),
+ ? _S_basic_spec_char()
+ : _S_extended_spec_char()),
_M_at_bracket_start(false)
{ }
@@ -138,46 +138,60 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_flags & regex_constants::awk; }
protected:
- const std::pair<char, _TokenT> _M_token_tbl[9] =
- {
- {'^', _S_token_line_begin},
- {'$', _S_token_line_end},
- {'.', _S_token_anychar},
- {'*', _S_token_closure0},
- {'+', _S_token_closure1},
- {'?', _S_token_opt},
- {'|', _S_token_or},
- {'\n', _S_token_or}, // grep and egrep
- {'\0', _S_token_or},
- };
- const std::pair<char, char> _M_ecma_escape_tbl[8] =
- {
- {'0', '\0'},
- {'b', '\b'},
- {'f', '\f'},
- {'n', '\n'},
- {'r', '\r'},
- {'t', '\t'},
- {'v', '\v'},
- {'\0', '\0'},
- };
- const std::pair<char, char> _M_awk_escape_tbl[11] =
- {
- {'"', '"'},
- {'/', '/'},
- {'\\', '\\'},
- {'a', '\a'},
- {'b', '\b'},
- {'f', '\f'},
- {'n', '\n'},
- {'r', '\r'},
- {'t', '\t'},
- {'v', '\v'},
- {'\0', '\0'},
- };
- const char* _M_ecma_spec_char = "^$\\.*+?()[]{}|";
- const char* _M_basic_spec_char = ".[\\*^$";
- const char* _M_extended_spec_char = ".[\\()*+?{|^$";
+ static const std::pair<char, _TokenT>* _S_token_tbl()
+ {
+ static const std::pair<char, _TokenT> __token_tbl[9] =
+ {
+ {'^', _S_token_line_begin},
+ {'$', _S_token_line_end},
+ {'.', _S_token_anychar},
+ {'*', _S_token_closure0},
+ {'+', _S_token_closure1},
+ {'?', _S_token_opt},
+ {'|', _S_token_or},
+ {'\n', _S_token_or}, // grep and egrep
+ {'\0', _S_token_or},
+ };
+ return __token_tbl;
+ }
+
+ static const std::pair<char, char>* _S_ecma_escape_tbl()
+ {
+ static const std::pair<char, char> __ecma_escape_tbl[8] =
+ {
+ {'0', '\0'},
+ {'b', '\b'},
+ {'f', '\f'},
+ {'n', '\n'},
+ {'r', '\r'},
+ {'t', '\t'},
+ {'v', '\v'},
+ {'\0', '\0'},
+ };
+ return __ecma_escape_tbl;
+ }
+ static const std::pair<char, char>* _S_awk_escape_tbl()
+ {
+ static const std::pair<char, char> __awk_escape_tbl[11] =
+ {
+ {'"', '"'},
+ {'/', '/'},
+ {'\\', '\\'},
+ {'a', '\a'},
+ {'b', '\b'},
+ {'f', '\f'},
+ {'n', '\n'},
+ {'r', '\r'},
+ {'t', '\t'},
+ {'v', '\v'},
+ {'\0', '\0'},
+ };
+ return __awk_escape_tbl;
+ }
+
+ static const char* _S_ecma_spec_char() { return "^$\\.*+?()[]{}|"; }
+ static const char* _S_basic_spec_char() { return ".[\\*^$"; }
+ static const char* _S_extended_spec_char() { return ".[\\()*+?{|^$"; }
_StateT _M_state;
_FlagT _M_flags;
@@ -170,7 +170,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
&& __c != '}')
|| (_M_is_grep() && __c == '\n'))
{
- auto __it = _M_token_tbl;
+ auto __it = _S_token_tbl();
auto __narrowc = _M_ctype.narrow(__c, '\0');
for (; __it->first != '\0'; ++__it)
if (__it->first == __narrowc)