locale_conv.h (__do_str_codecvt): Handle empty range.
authorJonathan Wakely <jwakely@redhat.com>
Mon, 22 Jun 2015 15:09:22 +0000 (16:09 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 22 Jun 2015 15:09:22 +0000 (16:09 +0100)
* include/bits/locale_conv.h (__do_str_codecvt): Handle empty range.
(wstring_convert): Move into __cxx11 namespace.
(wbuffer_convert(streambuf*, _Codecvt*, state_type)): Fix exception
message.

From-SVN: r224737

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/locale_conv.h

index 290af6851ce54c67eb1bef299d7c3e497334fb00..1e2fda0cf5a8706f09c87762c8c15f7ac6ee93e5 100644 (file)
@@ -1,5 +1,10 @@
 2015-06-22  Jonathan Wakely  <jwakely@redhat.com>
 
+       * include/bits/locale_conv.h (__do_str_codecvt): Handle empty range.
+       (wstring_convert): Move into __cxx11 namespace.
+       (wbuffer_convert(streambuf*, _Codecvt*, state_type)): Fix exception
+       message.
+
        PR libstdc++/64657
        * include/bits/stl_uninitialized.h
        (__uninitialized_copy::__uninit_copy): Cast expression to void.
index 61b535c57de104cd3e174f80a7518eedae63c5e0..fd99499b8f6bc5755f26820e08338ef2bf5fe86c 100644 (file)
@@ -58,6 +58,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                     _OutStr& __outstr, const _Codecvt& __cvt, _State& __state,
                     size_t& __count, _Fn __fn)
     {
+      if (__first == __last)
+       {
+         __outstr.clear();
+         return true;
+       }
+
       size_t __outchars = 0;
       auto __next = __first;
       const auto __maxlen = __cvt.max_length() + 1;
@@ -150,6 +156,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return __str_codecvt_out(__first, __last, __outstr, __cvt, __state, __n);
     }
 
+_GLIBCXX_BEGIN_NAMESPACE_CXX11
+
   /// String conversions
   template<typename _Codecvt, typename _Elem = wchar_t,
           typename _Wide_alloc = allocator<_Elem>,
@@ -301,6 +309,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       bool                     _M_with_strings = false;
     };
 
+_GLIBCXX_END_NAMESPACE_CXX11
+
   /// Buffer conversions
   template<typename _Codecvt, typename _Elem = wchar_t,
           typename _Tr = char_traits<_Elem>>
@@ -325,7 +335,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       : _M_buf(__bytebuf), _M_cvt(__pcvt), _M_state(__state)
       {
        if (!_M_cvt)
-         __throw_logic_error("wstring_convert");
+         __throw_logic_error("wbuffer_convert");
 
        _M_always_noconv = _M_cvt->always_noconv();