[glibmm] Restore lost #else block to fix build without __STDC_ISO_10646__



commit 7ba80a679895e04f0a68e07c27808f0411796bb0
Author: Koop Mast <kwm freebsd org>
Date:   Sat Jun 19 10:22:54 2010 +0200

    Restore lost #else block to fix build without __STDC_ISO_10646__
    
    	* glib/glibmm/ustring.cc: Add back an #else block that was probably lost
    	while automatically removing the no-exceptions #if/#else code.

 ChangeLog              |    7 +++++++
 glib/glibmm/ustring.cc |   15 +++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 73a37c6..58138d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-06-19  Koop Mast  <kwm freebsd org>
+
+	Restore lost #else block to fix build without __STDC_ISO_10646__
+
+	* glib/glibmm/ustring.cc: Add back an #else block that was probably lost 
+	while automatically removing the no-exceptions #if/#else code.
+	
 2010-06-18  José Alburquerque  <jaalburqu svn gnome org>
 
 	Preliminary implementation of Glib::Variant<> classes.
diff --git a/glib/glibmm/ustring.cc b/glib/glibmm/ustring.cc
index eb70b73..accf0d7 100644
--- a/glib/glibmm/ustring.cc
+++ b/glib/glibmm/ustring.cc
@@ -1354,7 +1354,12 @@ std::wistream& operator>>(std::wistream& is, ustring& utf8_string)
   glong n_bytes = 0;
   const ScopedPtr<char> buf (g_utf16_to_utf8(reinterpret_cast<const gunichar2*>(wstr.data()),
                                              wstr.size(), 0, &n_bytes, &error));
-#endif //GLIBMM_EXCEPTIONS_ENABLED
+#else
+  gsize n_bytes = 0;
+  const ScopedPtr<char> buf (g_convert(reinterpret_cast<const char*>(wstr.data()),
+                                       wstr.size() * sizeof(std::wstring::value_type),
+                                       "UTF-8", "WCHAR_T", 0, &n_bytes, &error));
+#endif // !(__STDC_ISO_10646__ || G_OS_WIN32)
 
   if (error)
   {
@@ -1378,7 +1383,13 @@ std::wostream& operator<<(std::wostream& os, const ustring& utf8_string)
   // Avoid going through iconv if wchar_t always contains UTF-16.
   const ScopedPtr<gunichar2> buf (g_utf8_to_utf16(utf8_string.raw().data(),
                                                   utf8_string.raw().size(), 0, 0, &error));
-#endif //GLIBMM_EXCEPTIONS_ENABLED
+#else
+  // TODO: For some reason the conversion from UTF-8 to WCHAR_T doesn't work
+  // with g_convert(), while iconv on the command line handles it just fine.
+  // Maybe a bug in GLib?
+  const ScopedPtr<char> buf (g_convert(utf8_string.raw().data(), utf8_string.raw().size(),
+                                       "WCHAR_T", "UTF-8", 0, 0, &error));
+#endif // !(__STDC_ISO_10646__ || G_OS_WIN32)
 
   if (error)
   {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]