[PATCH] Use Solaris iconv

Rainer Orth <[email protected]>
Newsgroups gmane.comp.gdb.patches
Message-ID <[email protected]>
Currently hundreds of tests FAIL on Solaris with

warning: could not convert '...' from the host encoding (ISO-8859-1) to UTF-32.
This normally should not happen, please file a bug report.

This happens because the system headers don't define __STDC_ISO_10646__
which was only introduced in C17.  However, Solaris libc only conforms
to C11.  Consequently PHONY_ICONV is defined, leading to those failures.

However, Solaris 11.4 iconv is good enough to use: enabling its use
fixes 300+ failures.

The results are on par with those using GNU libiconv 1.17, while
forcibly disabling HAVE_ICONV on Linux/x86_64 adds causes the same
amount of failures.

Tested on sparcv9-sun-solaris2.11, x86_64-pc-solaris2.11, and
x86_64-pc-solaris2.11.

Ok for trunk?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
sol2-iconv.patch (text/x-patch, 1.9 KB)
# HG changeset patch
# Parent  97bd89d84470fc76016c1f0a387cad83b62d0c7a
Use Solaris iconv

diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h
--- a/gdb/gdb_wchar.h
+++ b/gdb/gdb_wchar.h
@@ -34,10 +34,12 @@
    functionality is available to the user, but many characters (those
    outside the narrow range) will be displayed as escapes.
 
-   Finally, some systems do not have iconv, or are really broken
-   (e.g., Solaris, which almost has all of this working, but where
-   just enough is broken to make it too hard to use).  Here we provide
-   a phony iconv which only handles a single character set, and we
+   While the Solaris 11.4 system headers don't define __STDC_ISO_10646__
+   (it's a C17 addition while Solaris libc only conforms to C11), the
+   system iconv works well enough.
+
+   Finally, some systems do not have iconv, or are really broken.  Here we
+   provide a phony iconv which only handles a single character set, and we
    provide wrappers for the wchar_t functionality we use.  */
 
 
@@ -59,7 +61,8 @@
    iconvlist.  */
 #if defined (HAVE_ICONV) && defined (HAVE_BTOWC) \
   && (defined (__STDC_ISO_10646__) \
-      || (defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x108))
+      || (defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x108) \
+      || (defined (__sun__) && defined (__svr4__)))
 
 using gdb_wchar_t = wchar_t;
 using gdb_wint_t = wint_t;
@@ -88,7 +91,8 @@ using gdb_wint_t = wint_t;
    Sonoma specifically, but it is desirable for binaries built for
    older versions of macOS to still work on newer ones such as Sonoma,
    so there is no version check here for this workaround.  */
-#if defined (__STDC_ISO_10646__) || defined (__APPLE__)
+#if defined (__STDC_ISO_10646__) || defined (__APPLE__) \
+  || (defined (__sun__) && defined (__svr4__))
 #define USE_INTERMEDIATE_ENCODING_FUNCTION
 #define INTERMEDIATE_ENCODING intermediate_encoding ()
 const char *intermediate_encoding (void);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.