diff mbox

[libstdc++/64680] Conform the standard regex interface

Message ID CAG4ZjNnt+pObRS0f7E3vHnLmpPLUrjPEnCb2Av2EKFWaFBe1Fg@mail.gmail.com
State New
Headers show

Commit Message

Tim Shen Jan. 21, 2015, 4:05 a.m. UTC
On Tue, Jan 20, 2015 at 9:04 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> When we end up doing this to save run time, let's at least add in a comment
> the PR #, like
>
>     // PR libstdc++/64680
>
> before test02().

Certainly.

Comments

Jonathan Wakely Jan. 21, 2015, 11:51 a.m. UTC | #1
On 20/01/15 20:05 -0800, Tim Shen wrote:
>On Tue, Jan 20, 2015 at 9:04 AM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
>> When we end up doing this to save run time, let's at least add in a comment
>> the PR #, like
>>
>>     // PR libstdc++/64680
>>
>> before test02().
>
>Certainly.
>
>
>-- 
>Regards,
>Tim Shen

>commit a150869847b7b02f57873fc18853b144a61c8880
>Author: timshen <timshen@google.com>
>Date:   Tue Jan 20 00:20:14 2015 -0800
>
>    	PR libstdc++/64680
>    	* include/bits/regex.h (basic_regex<>::basic_regex,
>    	basic_regex<>::operator=, basic_regex<>::imbue): Conform the

"Conform to ..."

>    	standard interface.
>    	* testsuite/28_regex/basic_regex/assign/char/cstring.cc: New testcase.

As it's a tiny change it's OK for trunk with that tweak to the changelog.

(Any more non-regression regex bugs that get reported might have to
wait for stage 1 and get fixed for the next release)
Tim Shen Jan. 22, 2015, 5:08 a.m. UTC | #2
On Wed, Jan 21, 2015 at 3:51 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
> "Conform to ..."
>
>>         standard interface.
>>         * testsuite/28_regex/basic_regex/assign/char/cstring.cc: New
>> testcase.
>
>
> As it's a tiny change it's OK for trunk with that tweak to the changelog.
>
> (Any more non-regression regex bugs that get reported might have to
> wait for stage 1 and get fixed for the next release)

Fixed and committed.
Tim Shen Feb. 1, 2015, 8:18 a.m. UTC | #3
On Wed, Jan 21, 2015 at 9:08 PM, Tim Shen <timshen@google.com> wrote:
> Fixed and committed.

I believe this one is also suitable for 4.9?

I guess we don't have a 'code freeze' for 4.9 branch as we do for 5.0
late stage?
Jonathan Wakely Feb. 2, 2015, 11:19 a.m. UTC | #4
On 01/02/15 00:18 -0800, Tim Shen wrote:
>On Wed, Jan 21, 2015 at 9:08 PM, Tim Shen <timshen@google.com> wrote:
>> Fixed and committed.
>
>I believe this one is also suitable for 4.9?
>
>I guess we don't have a 'code freeze' for 4.9 branch as we do for 5.0
>late stage?

Release branches are always in "regression fixes and docs only" mode,
but this is OK for 4.9, thanks.
diff mbox

Patch

diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 6de883a..07c78b7 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -442,7 +442,7 @@  _GLIBCXX_BEGIN_NAMESPACE_CXX11
        */
       explicit
       basic_regex(const _Ch_type* __p, flag_type __f = ECMAScript)
-      : basic_regex(__p, __p + _Rx_traits::length(__p), __f)
+      : basic_regex(__p, __p + char_traits<_Ch_type>::length(__p), __f)
       { }
 
       /**
@@ -553,7 +553,19 @@  _GLIBCXX_BEGIN_NAMESPACE_CXX11
        */
       basic_regex&
       operator=(const _Ch_type* __p)
-      { return this->assign(__p, flags()); }
+      { return this->assign(__p); }
+
+      /**
+       * @brief Replaces a regular expression with a new one constructed from
+       * an initializer list.
+       *
+       * @param __l  The initializer list.
+       *
+       * @throws regex_error if @p __l is not a valid regular expression.
+       */
+      basic_regex&
+      operator=(initializer_list<_Ch_type> __l)
+      { return this->assign(__l.begin(), __l.end()); }
 
       /**
        * @brief Replaces a regular expression with a new one constructed from
@@ -564,7 +576,7 @@  _GLIBCXX_BEGIN_NAMESPACE_CXX11
       template<typename _Ch_traits, typename _Alloc>
 	basic_regex&
 	operator=(const basic_string<_Ch_type, _Ch_traits, _Alloc>& __s)
-	{ return this->assign(__s, flags()); }
+	{ return this->assign(__s); }
 
       // [7.8.3] assign
       /**
@@ -712,7 +724,7 @@  _GLIBCXX_BEGIN_NAMESPACE_CXX11
       imbue(locale_type __loc)
       {
 	std::swap(__loc, _M_loc);
-	_M_automaton = nullptr;
+	_M_automaton.reset();
 	return __loc;
       }
 
diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc
index 19528b6..6794fff 100644
--- a/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc
+++ b/libstdc++-v3/testsuite/28_regex/basic_regex/assign/char/cstring.cc
@@ -36,9 +36,19 @@  void test01()
   re.assign(cs);
 }
 
+// basic_regex::operator=() resets flags. libstdc++/64680
+void test02()
+{
+  bool test __attribute__((unused)) = true;
+
+  std::regex re("[[:alnum:]]", std::regex_constants::basic);
+  re = "\\w+";
+}
+
 int
 main()
 { 
   test01();
+  test02();
   return 0;
 }