Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Subject: Re: Iconv / Solaris
Date: Fri, 28 Aug 2009 17:00:00 -0000	[thread overview]
Message-ID: <m3ab1joqvf.fsf@fleche.redhat.com> (raw)
In-Reply-To: <m3hbvspx99.fsf@fleche.redhat.com> (Tom Tromey's message of "Thu, 	27 Aug 2009 19:01:22 -0600")

>>>>> "Tom" == Tom Tromey <tromey@redhat.com> writes:

Tom> I can write a patch tomorrow.

Please try the appended.  You will have to re-run autoheader and
autoconf.

I took the opportunity to add more text to the comment in gdb_wchar.h,
in the hopes that this would make it more clear.

If this works for you, I will check it in.

Tom

2009-08-28  Tom Tromey  <tromey@redhat.com>

	* gdb_wchar.h: Update comments.  Use DISABLE_ICONV.
	* configure, config.in: Rebuild.
	* configure.ac (DISABLE_ICONV): Define when needed.
	* configure.host: Set gdb_host_wchar_iconv.

Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.105
diff -u -r1.105 configure.ac
--- configure.ac	22 Aug 2009 17:08:09 -0000	1.105
+++ configure.ac	28 Aug 2009 16:15:22 -0000
@@ -788,6 +788,12 @@
 		ttrace wborder setlocale iconvlist libiconvlist btowc])
 AM_LANGINFO_CODESET
 
+# An additional check for whether iconv is ok for us to use.
+if test "$gdb_host_wchar_iconv" = no; then
+  AC_DEFINE([DISABLE_ICONV], 1,
+            [Define if host iconv is unsuitable for use by gdb])
+fi
+
 # Check the return and argument types of ptrace.  No canned test for
 # this, so roll our own.
 gdb_ptrace_headers='
Index: configure.host
===================================================================
RCS file: /cvs/src/src/gdb/configure.host,v
retrieving revision 1.103
diff -u -r1.103 configure.host
--- configure.host	11 Jan 2009 13:15:56 -0000	1.103
+++ configure.host	28 Aug 2009 16:15:22 -0000
@@ -8,6 +8,8 @@
 #  gdb_host_double_format	host's double floatformat, or 0
 #  gdb_host_long_double_format	host's long double floatformat, or 0
 #  gdb_host_obs			host-specific .o files to include
+#  gdb_host_wchar_iconv		"no" if iconv_open will not accept
+#				"wchar_t" as an argument.
 
 # Map host cpu into the config cpu subdirectory name.
 # The default is $host_cpu.
@@ -207,3 +209,15 @@
 	gdb_host_long_double_format=0
 	;;
 esac
+
+
+# Per-host iconv setting.
+
+# Default to "yes".
+gdb_host_wchar_iconv=yes
+
+case "${host}" in
+*-*-solaris*)
+	gdb_host_wchar_iconv=no
+	;;
+esac
Index: gdb_wchar.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_wchar.h,v
retrieving revision 1.2
diff -u -r1.2 gdb_wchar.h
--- gdb_wchar.h	15 Apr 2009 22:20:31 -0000	1.2
+++ gdb_wchar.h	28 Aug 2009 16:15:22 -0000
@@ -21,18 +21,33 @@
 
 /* We handle three different modes here.
    
-   Capable systems have the full suite: wchar_t support and iconv
+   1. Capable systems have the full suite: wchar_t support and iconv
    (perhaps via GNU libiconv).  On these machines, full functionality
-   is available.
+   is available.  In this case, the intermediate character set is
+   "wchar_t".
    
-   DJGPP is known to have libiconv but not wchar_t support.  On
+   2. DJGPP is known to have libiconv but not wchar_t support.  On
    systems like this, we use the narrow character functions.  The full
    functionality is available to the user, but many characters (those
-   outside the narrow range) will be displayed as escapes.
+   outside the narrow range) will be displayed as escapes.  In this
+   case, the intermediate character set uses the host encoding.
    
-   Finally, some systems do not have iconv.  Here we provide a phony
-   iconv which only handles a single character set, and we provide
-   wrappers for the wchar_t functionality we use.  */
+   We also end up in this scenario if the host iconv is not fully
+   suitable.  Solaris falls into this category both because iconv_open
+   does not accept "wchar_t" as an argument, but also because wchar_t
+   does not have a fixed encoding.
+
+   3. Finally, some systems do not have iconv.  Here we provide a
+   phony iconv which only handles a single character set, and we
+   provide wrappers for the wchar_t functionality we use.  This is
+   what the "PHONY_ICONV" define means, below. In this case, the
+   intermediate character set uses the host encoding, and limited
+   functionality is available to the user.
+   
+   It is possible that you may run into a system that does not support
+   "wchar_t" as an argument to iconv_open, but where
+   __STDC_ISO_10646__ is defined.  If you have such a system, we can
+   add a fourth case where we fix the intermediate encoding.  */
 
 
 #define INTERMEDIATE_ENCODING "wchar_t"
@@ -40,14 +55,17 @@
 #if defined (HAVE_ICONV)
 #include <iconv.h>
 #else
-/* This define is used elsewhere so we don't need to duplicate the
-   same checking logic in multiple places.  */
+/* Case 3.  This define is used elsewhere so we don't need to
+   duplicate the same checking logic in multiple places.  */
 #define PHONY_ICONV
 #endif
 
 /* We use "btowc" as a sentinel to detect functioning wchar_t
    support.  */
-#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC)
+#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC) \
+  && !defined (DISABLE_ICONV)
+
+/* Case 1.  */
 
 #include <wchar.h>
 #include <wctype.h>
@@ -65,6 +83,8 @@
 
 #else
 
+/* Case 2 and case 3, depending on whether PHONY_ICONV is defined.  */
+
 typedef char gdb_wchar_t;
 typedef int gdb_wint_t;
 


      reply	other threads:[~2009-08-28 16:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-27  2:22 Daniel Jacobowitz
2009-08-27 17:09 ` Tom Tromey
2009-08-27 17:45   ` Daniel Jacobowitz
2009-08-27 20:36     ` Tom Tromey
2009-08-27 20:38       ` Daniel Jacobowitz
2009-08-27 20:50         ` Daniel Jacobowitz
2009-08-27 22:03           ` Daniel Jacobowitz
2009-08-28  1:01           ` Tom Tromey
2009-08-28  1:24         ` Tom Tromey
2009-08-28 17:00           ` Tom Tromey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3ab1joqvf.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox