]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/bits/regex_scanner.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / include / bits / regex_scanner.h
index 6dc2b4edf6f11e65314b3a5342ce27aca50c721d..0fc3ed41078c137801c1dcebb14666f36c068c99 100644 (file)
@@ -1,6 +1,6 @@
 // class template regex -*- C++ -*-
 
-// Copyright (C) 2013-2014 Free Software Foundation, Inc.
+// Copyright (C) 2013-2020 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
-namespace __detail
-{
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+namespace __detail
+{
   /**
    * @addtogroup regex-detail
    * @{
@@ -43,7 +43,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
   public:
     /// Token types returned from the scanner.
-    enum _TokenT
+    enum _TokenT : unsigned
     {
       _S_token_anychar,
       _S_token_ord_char,
@@ -67,14 +67,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _S_token_or,
       _S_token_closure0,
       _S_token_closure1,
-      _S_token_ungreedy,
       _S_token_line_begin,
       _S_token_line_end,
       _S_token_word_bound, // neg if _M_value[0] == 'n'
       _S_token_comma,
       _S_token_dup_count,
       _S_token_eof,
-      _S_token_unknown
+      _S_token_bracket_dash,
+      _S_token_unknown = -1u
     };
 
   protected:
@@ -96,11 +96,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                  : _M_awk_escape_tbl),
     _M_spec_char(_M_is_ecma()
                 ? _M_ecma_spec_char
-                : _M_is_basic()
+                : _M_flags & regex_constants::basic
                 ? _M_basic_spec_char
-                : _M_extended_spec_char),
+                : _M_flags & regex_constants::extended
+                ? _M_extended_spec_char
+                : _M_flags & regex_constants::grep
+                ?  ".[\\*^$\n"
+                : _M_flags & regex_constants::egrep
+                ? ".[\\()*+?{|^$\n"
+                : _M_flags & regex_constants::awk
+                ? _M_extended_spec_char
+                : nullptr),
     _M_at_bracket_start(false)
-    { }
+    { __glibcxx_assert(_M_spec_char); }
 
   protected:
     const char*
@@ -138,6 +146,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     { return _M_flags & regex_constants::awk; }
 
   protected:
+    // TODO: Make them static in the next abi change.
     const std::pair<char, _TokenT> _M_token_tbl[9] =
       {
        {'^', _S_token_line_begin},
@@ -188,7 +197,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   };
 
   /**
-   * @brief struct _Scanner. Scans an input range for regex tokens.
+   * @brief Scans an input range for regex tokens.
    *
    * The %_Scanner class interprets the regular expression pattern in
    * the input range passed to its constructor as a sequence of parse
@@ -256,8 +265,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
  //@} regex-detail
-_GLIBCXX_END_NAMESPACE_VERSION
 } // namespace __detail
+_GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
 
 #include <bits/regex_scanner.tcc>