diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-10-09 18:38:34 +0800 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-11-01 14:05:14 +0800 |
| commit | 74ed102cabcdede68effff2b2cbaa038b936c76c (patch) | |
| tree | 0c3f6d2d8245d8e162dfad8864ff8799d1f1dd16 /src/regex_impl.cc | |
| parent | df73b71dfcfa45b811887d5a78133664e43a748d (diff) | |
Regex: Tweak definition of character class and control escape tables
Diffstat (limited to 'src/regex_impl.cc')
| -rw-r--r-- | src/regex_impl.cc | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/regex_impl.cc b/src/regex_impl.cc index 11290054..178a5b9f 100644 --- a/src/regex_impl.cc +++ b/src/regex_impl.cc @@ -489,30 +489,32 @@ private: Iterator m_pos; bool m_ignore_case = false; - struct CharacterClassEscape { + static constexpr struct CharacterClassEscape { Codepoint cp; const char* ctype; StringView additional_chars; bool neg; + } character_class_escapes[] = { + { 'd', "digit", "", false }, + { 'w', "alnum", "_", false }, + { 's', "space", "", false }, + { 'h', nullptr, " \t", false }, }; - static const CharacterClassEscape character_class_escapes[4]; - struct ControlEscape { Codepoint name; Codepoint value; }; - static const ControlEscape control_escapes[5]; -}; - -// For some reason Gcc fails to link if this is constexpr -const RegexParser::CharacterClassEscape RegexParser::character_class_escapes[4] = { - { 'd', "digit", "", false }, - { 'w', "alnum", "_", false }, - { 's', "space", "", false }, - { 'h', nullptr, " \t", false }, + static constexpr struct ControlEscape { + Codepoint name; + Codepoint value; + } control_escapes[] = { + { 'f', '\f' }, + { 'n', '\n' }, + { 'r', '\r' }, + { 't', '\t' }, + { 'v', '\v' } + }; }; - -const RegexParser::ControlEscape RegexParser::control_escapes[5] = { - { 'f', '\f' }, { 'n', '\n' }, { 'r', '\r' }, { 't', '\t' }, { 'v', '\v' } -}; +constexpr RegexParser::CharacterClassEscape RegexParser::character_class_escapes[]; +constexpr RegexParser::ControlEscape RegexParser::control_escapes[]; struct RegexCompiler { |
