This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] Fix wide char iconv problem on Solaris


  This is really a preliminary
RFC to show how I was able to
to get correct string display again on OpenSolaris.

  The problem with OpenSolaris is that 'wchar_t' is not recognized as
a charset name.
  This can be solved by adding an alias 
into /usr/lib/iconv/alias file, but you
need administrative rights for this...

  The patch below tests
'wchar_t', 'UTF32-LE' and finally host_charset ()
as entries for iconv_open.
  A real patch should probably 
accommodate the second to:
  the value of SIZEOF_WCHAR_T if available in config.h
and the endianess of the host.

  The main idea is to use a variable
instead of a fixed macro for
intermediate_encoding.

  Comments?
  

Pierre Muller
Pascal language support maintainer for GDB


 
2010-04-21  Pierre Muller  <muller@ics.u-strasbg.fr>

	* c-lang.c (c_emit_char): Use intermediate_encoding variable
	in replacment of INTERMEDIATE_ENCODING macro.
	(c_printstr): Likewise.
	* charset.c i(intermediate_encoding): New variable.
	(make_wchar_iterator): Use intermediate_encoding variable
	and set it to successful iconv_open call.
	* gdb_wchar.h (intermediate_encoding):a New external.

Index: src/gdb/c-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/c-lang.c,v
retrieving revision 1.81
diff -u -p -r1.81 c-lang.c
--- src/gdb/c-lang.c	5 Mar 2010 20:18:11 -0000	1.81
+++ src/gdb/c-lang.c	21 Apr 2010 14:01:31 -0000
@@ -324,7 +324,7 @@ c_emit_char (int c, struct type *type, s
   obstack_init (&output);
   make_cleanup_obstack_free (&output);
 
-  convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
+  convert_between_encodings (intermediate_encoding, host_charset (),
 			     obstack_base (&wchar_buf),
 			     obstack_object_size (&wchar_buf),
 			     1, &output, translit_char);
@@ -596,7 +596,7 @@ c_printstr (struct ui_file *stream, stru
   obstack_init (&output);
   make_cleanup_obstack_free (&output);
 
-  convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
+  convert_between_encodings (intermediate_encoding, host_charset (),
 			     obstack_base (&wchar_buf),
 			     obstack_object_size (&wchar_buf),
 			     1, &output, translit_char);
Index: src/gdb/charset.c
===================================================================
RCS file: /cvs/src/src/gdb/charset.c,v
retrieving revision 1.31
diff -u -p -r1.31 charset.c
--- src/gdb/charset.c	6 Apr 2010 17:47:40 -0000	1.31
+++ src/gdb/charset.c	21 Apr 2010 14:01:31 -0000
@@ -74,6 +74,8 @@
    GDB simply requires a capable iconv function.  Users on platforms
    without a suitable iconv can use the GNU iconv library.  */
 
+
+const char *intermediate_encoding = INTERMEDIATE_ENCODING;
 

 #ifdef PHONY_ICONV
 
@@ -580,7 +582,23 @@ make_wchar_iterator (const gdb_byte *inp
   struct wchar_iterator *result;
   iconv_t desc;
 
-  desc = iconv_open (INTERMEDIATE_ENCODING, charset);
+  desc = iconv_open (intermediate_encoding, charset);
+  if (desc == (iconv_t) -1)
+    {
+      static char utfname[] = "UTF-32LE";
+      desc = iconv_open (utfname, charset);
+      if (desc != (iconv_t) -1)
+	intermediate_encoding = utfname;
+    }
+  if (desc == (iconv_t) -1)
+    {
+      desc = iconv_open (host_charset (), charset);
+      if (desc != (iconv_t) -1)
+	{
+	  intermediate_encoding = xmalloc (sizeof (host_charset ()));
+	  strcpy ((char *) intermediate_encoding, host_charset ());
+	}
+    }
   if (desc == (iconv_t) -1)
     perror_with_name ("Converting character sets");
 
Index: src/gdb/gdb_wchar.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_wchar.h,v
retrieving revision 1.3
diff -u -p -r1.3 gdb_wchar.h
--- src/gdb/gdb_wchar.h	1 Jan 2010 07:31:32 -0000	1.3
+++ src/gdb/gdb_wchar.h	21 Apr 2010 14:01:35 -0000
@@ -55,6 +55,8 @@
 typedef wchar_t gdb_wchar_t;
 typedef wint_t gdb_wint_t;
 
+extern const char *intermediate_encoding;
+
 #define gdb_wcslen wcslen
 #define gdb_iswprint iswprint
 #define gdb_iswdigit iswdigit



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]