[cfe-commits] [libcxx] r160136 - in /libcxx/trunk: include/locale test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp

Howard Hinnant hhinnant at apple.com
Thu Jul 12 11:07:41 PDT 2012


Author: hhinnant
Date: Thu Jul 12 13:07:41 2012
New Revision: 160136

URL: http://llvm.org/viewvc/llvm-project?rev=160136&view=rev
Log:
Fixed a bug in wstring_convert concerning zero-length inputs.  Thanks to Jonathan Coxhead for reporting this bug.

Modified:
    libcxx/trunk/include/locale
    libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
    libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp

Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=160136&r1=160135&r2=160136&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Thu Jul 12 13:07:41 2012
@@ -3920,7 +3920,8 @@
     if (__cvtptr_ != nullptr)
     {
         wide_string __ws(2*(__frm_end - __frm), _Elem());
-        __ws.resize(__ws.capacity());
+        if (__frm != __frm_end)
+            __ws.resize(__ws.capacity());
         codecvt_base::result __r = codecvt_base::ok;
         state_type __st = __cvtstate_;
         if (__frm != __frm_end)
@@ -3980,7 +3981,8 @@
     if (__cvtptr_ != nullptr)
     {
         byte_string __bs(2*(__frm_end - __frm), char());
-        __bs.resize(__bs.capacity());
+        if (__frm != __frm_end)
+            __bs.resize(__bs.capacity());
         codecvt_base::result __r = codecvt_base::ok;
         state_type __st = __cvtstate_;
         if (__frm != __frm_end)

Modified: libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp?rev=160136&r1=160135&r2=160136&view=diff
==============================================================================
--- libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp (original)
+++ libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp Thu Jul 12 13:07:41 2012
@@ -33,5 +33,7 @@
         assert(ws == L"\x40003");
         ws = myconv.from_bytes(bs.data(), bs.data() + bs.size());
         assert(ws == L"\x40003");
+        ws = myconv.from_bytes("");
+        assert(ws.size() == 0);
     }
 }

Modified: libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp?rev=160136&r1=160135&r2=160136&view=diff
==============================================================================
--- libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp (original)
+++ libcxx/trunk/test/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp Thu Jul 12 13:07:41 2012
@@ -33,5 +33,7 @@
         assert(bs == "\xF1\x80\x80\x83");
         bs = myconv.to_bytes(ws.data(), ws.data() + ws.size());
         assert(bs == "\xF1\x80\x80\x83");
+        bs = myconv.to_bytes(L"");
+        assert(bs.size() == 0);
     }
 }





More information about the cfe-commits mailing list