regex_error.h: Remove _S_error_last to follow the standard.
authorTim Shen <timshen91@gmail.com>
Thu, 26 Sep 2013 21:48:04 +0000 (21:48 +0000)
committerTim Shen <timshen@gcc.gnu.org>
Thu, 26 Sep 2013 21:48:04 +0000 (21:48 +0000)
2013-09-26  Tim Shen  <timshen91@gmail.com>

* regex_error.h: Remove _S_error_last to follow the standard.
* regex_scanner.tcc:
(_Scanner<_FwdIter>::_M_scan_in_brace): Change error_brace to
error_badbrace.
(_Scanner<>::_M_eat_escape_posix): Extended doesn't support
back-reference.
* testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc:
Move here from ../../extended.
* testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc:
Likewise.

From-SVN: r202958

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/regex_error.h
libstdc++-v3/include/bits/regex_scanner.tcc
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc [new file with mode: 0644]
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc [new file with mode: 0644]
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/53622.cc [deleted file]
libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/57173.cc [deleted file]

index ae914b969aa81b890fdc83222bb710aadd2894c0..fe1550810cb559d45bf578492f7f52a5b6349c09 100644 (file)
@@ -1,3 +1,16 @@
+2013-09-26  Tim Shen  <timshen91@gmail.com>
+
+       * regex_error.h: Remove _S_error_last to follow the standard.
+       * regex_scanner.tcc:
+       (_Scanner<_FwdIter>::_M_scan_in_brace): Change error_brace to
+       error_badbrace.
+       (_Scanner<>::_M_eat_escape_posix): Extended doesn't support
+       back-reference.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc:
+       Move here from ../../extended.
+       * testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc:
+       Likewise.
+
 2013-09-25  Marc Glisse  <marc.glisse@inria.fr>
 
        PR libstdc++/58338
index 7f06727bfae50ded55b030078fdac416a8b83c4d..a39a8ea1a8f96ef2154f35b24262a93800f183a2 100644 (file)
@@ -61,7 +61,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _S_error_badrepeat,
       _S_error_complexity,
       _S_error_stack,
-      _S_error_last
     };
 
   /** The expression contained an invalid collating element name. */
index abdbcc64f1f3b4d9d41b728268f3e2b581a75b0f..e0dff9009c604107c56d000ddda9312e5bef0cf7 100644 (file)
@@ -345,7 +345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
              ++_M_current;
            }
          else
-           __throw_regex_error(regex_constants::error_brace);
+           __throw_regex_error(regex_constants::error_badbrace);
        }
       else if (__c == '}')
        {
@@ -353,7 +353,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          _M_token = _S_token_interval_end;
        }
       else
-       __throw_regex_error(regex_constants::error_brace);
+       __throw_regex_error(regex_constants::error_badbrace);
     }
 
   template<typename _FwdIter>
@@ -428,6 +428,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        }
     }
 
+  // Differences between styles:
+  // 1) Extended doesn't support backref, but basic does.
   template<typename _FwdIter>
     void
     _Scanner<_FwdIter>::
@@ -449,7 +451,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          _M_eat_escape_awk();
          return;
        }
-      else if (_M_ctype.is(_CtypeT::digit, __c) && __c != '0')
+      else if (_M_is_basic() && _M_ctype.is(_CtypeT::digit, __c) && __c != '0')
        {
          _M_token = _S_token_backref;
          _M_value.assign(1, __c);
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/53622.cc
new file mode 100644 (file)
index 0000000..5f4b1d1
--- /dev/null
@@ -0,0 +1,66 @@
+// { dg-options "-std=gnu++11" }
+
+//
+// 2013-07-23  Tim Shen <timshen91@gmail.com>
+//
+// Copyright (C) 2013 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+// libstdc++/53622
+void
+test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  {
+    std::regex  re("zxcv/(one.*)abc", std::regex::ECMAScript);
+    std::string target("zxcv/onetwoabc");
+    std::smatch m;
+
+    VERIFY( std::regex_match(target, m, re) );
+    VERIFY( m.size() == 2 );
+    VERIFY( m[0].matched == true );
+    VERIFY( std::string(m[0].first, m[0].second) == "zxcv/onetwoabc" );
+    VERIFY( m[1].matched == true );
+    VERIFY( std::string(m[1].first, m[1].second) == "onetwo" );
+  }
+
+  {
+    std::regex  re("zxcv/(one.*)abc()\\2", std::regex::ECMAScript);
+    std::string target("zxcv/onetwoabc");
+    std::smatch m;
+
+    VERIFY( std::regex_match(target, m, re) );
+    VERIFY( m.size() == 3 );
+    VERIFY( m[0].matched == true );
+    VERIFY( std::string(m[0].first, m[0].second) == "zxcv/onetwoabc" );
+    VERIFY( m[1].matched == true );
+    VERIFY( std::string(m[1].first, m[1].second) == "onetwo" );
+  }
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/ecma/char/57173.cc
new file mode 100644 (file)
index 0000000..b9a72c9
--- /dev/null
@@ -0,0 +1,60 @@
+// { dg-options "-std=gnu++11" }
+
+//
+// 2013-07-23  Tim Shen <timshen91@gmail.com>
+//
+// Copyright (C) 2013 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// 28.11.2 regex_match
+
+#include <regex>
+#include <testsuite_hooks.h>
+#include <iostream>
+
+// libstdc++/57173
+void
+test01()
+{
+  bool test __attribute__((unused)) = true;
+
+  {
+    std::regex  re("/asdf(/.*)", std::regex::ECMAScript);
+    std::string target("/asdf/qwerty");
+    std::smatch m;
+
+    VERIFY( std::regex_match(target, m, re) );
+    VERIFY( m.size() == 2 );
+    VERIFY( std::string(m[1].first, m[1].second) == "/qwerty");
+  }
+  {
+    std::regex  re("/asdf(/.*)()\\2", std::regex::ECMAScript);
+    std::string target("/asdf/qwerty");
+    std::smatch m;
+
+    VERIFY( std::regex_match(target, m, re) );
+    VERIFY( m.size() == 3 );
+    VERIFY( std::string(m[1].first, m[1].second) == "/qwerty");
+  }
+}
+
+int
+main()
+{
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/53622.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/53622.cc
deleted file mode 100644 (file)
index aee1dbe..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// { dg-options "-std=gnu++11" }
-
-//
-// 2013-07-23  Tim Shen <timshen91@gmail.com>
-//
-// Copyright (C) 2013 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
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// 28.11.2 regex_match
-// Tests Extended grouping against a std::string target.
-
-#include <regex>
-#include <testsuite_hooks.h>
-
-// libstdc++/53622
-void
-test01()
-{
-  bool test __attribute__((unused)) = true;
-
-  {
-    std::regex  re("zxcv/(one.*)abc", std::regex::extended);
-    std::string target("zxcv/onetwoabc");
-    std::smatch m;
-
-    VERIFY( std::regex_match(target, m, re) );
-    VERIFY( m.size() == 2 );
-    VERIFY( m[0].matched == true );
-    VERIFY( std::string(m[0].first, m[0].second) == "zxcv/onetwoabc" );
-    VERIFY( m[1].matched == true );
-    VERIFY( std::string(m[1].first, m[1].second) == "onetwo" );
-  }
-
-  {
-    std::regex  re("zxcv/(one.*)abc()\\2", std::regex::extended);
-    std::string target("zxcv/onetwoabc");
-    std::smatch m;
-
-    VERIFY( std::regex_match(target, m, re) );
-    VERIFY( m.size() == 3 );
-    VERIFY( m[0].matched == true );
-    VERIFY( std::string(m[0].first, m[0].second) == "zxcv/onetwoabc" );
-    VERIFY( m[1].matched == true );
-    VERIFY( std::string(m[1].first, m[1].second) == "onetwo" );
-  }
-}
-
-int
-main()
-{
-  test01();
-  return 0;
-}
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/57173.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/extended/57173.cc
deleted file mode 100644 (file)
index cb3a54f..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-// { dg-options "-std=gnu++11" }
-
-//
-// 2013-07-23  Tim Shen <timshen91@gmail.com>
-//
-// Copyright (C) 2013 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
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-// 28.11.3 regex_search
-// Tests Extended against a std::string target.
-
-#include <regex>
-#include <testsuite_hooks.h>
-#include <iostream>
-
-// libstdc++/57173
-void
-test01()
-{
-  bool test __attribute__((unused)) = true;
-
-  {
-    std::regex  re("/asdf(/.*)", std::regex::extended);
-    std::string target("/asdf/qwerty");
-    std::smatch m;
-
-    VERIFY( std::regex_match(target, m, re) );
-    VERIFY( m.size() == 2 );
-    VERIFY( std::string(m[1].first, m[1].second) == "/qwerty");
-  }
-  {
-    std::regex  re("/asdf(/.*)()\\2", std::regex::extended);
-    std::string target("/asdf/qwerty");
-    std::smatch m;
-
-    VERIFY( std::regex_match(target, m, re) );
-    VERIFY( m.size() == 3 );
-    VERIFY( std::string(m[1].first, m[1].second) == "/qwerty");
-  }
-}
-
-int
-main()
-{
-  test01();
-  return 0;
-}