Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: Configuring gdb_wchar.h
Date: Mon, 13 Apr 2009 17:54:00 -0000	[thread overview]
Message-ID: <m3tz4smocb.fsf@fleche.redhat.com> (raw)
In-Reply-To: <8363hboz5x.fsf@gnu.org> (Eli Zaretskii's message of "Sat\, 11 Apr 2009 20\:52\:58 +0300")

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

Eli> The actual case in point is the DJGPP build.  The DJGPP library has
Eli> wchar.h and there's a port of libiconv, but the functions gdb_wchar.h
Eli> expects for wide character support are not there.

Thanks for the report.

Please try the appended patch.  I've included the auto* output in this
patch in case you don't have the right versions on your DJGPP machine.

I chose btowc as a sentinel function.  And, I separated out the "phony
iconv" and "wchar_t support" cases, so that systems that have the
former but not the latter will gracefully choose slightly degraded
functionality.

Tom

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b6f86a7..f2b19c3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2009-04-13  Tom Tromey  <tromey@redhat.com>
+
+	* c-lang.c (c_emit_char): Use INTERMEDIATE_ENCODING.
+	(c_printstr): Likewise.
+	* charset.c (make_wchar_iterator): Use INTERMEDIATE_ENCODING.
+	* gdb_wchar.h: Check HAVE_BTOWC.  Split PHONY_ICONV and wchar
+	cases.
+	(INTERMEDIATE_ENCODING): New define.
+	* configure, config.in: Rebuild.
+	* configure.ac: Check for btowc.
+
 2009-04-10  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	* gdbtypes.c: Remove excessive parentheses at the return keywords.
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 0c9e4f8..139d219 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -296,7 +296,7 @@ c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
   obstack_init (&output);
   make_cleanup_obstack_free (&output);
 
-  convert_between_encodings ("wchar_t", host_charset (),
+  convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
 			     obstack_base (&wchar_buf),
 			     obstack_object_size (&wchar_buf),
 			     1, &output, translit_char);
@@ -562,7 +562,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
   obstack_init (&output);
   make_cleanup_obstack_free (&output);
 
-  convert_between_encodings ("wchar_t", host_charset (),
+  convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
 			     obstack_base (&wchar_buf),
 			     obstack_object_size (&wchar_buf),
 			     1, &output, translit_char);
diff --git a/gdb/charset.c b/gdb/charset.c
index 14862e7..c358940 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -527,7 +527,7 @@ make_wchar_iterator (const gdb_byte *input, size_t bytes, const char *charset,
   struct wchar_iterator *result;
   iconv_t desc;
 
-  desc = iconv_open ("wchar_t", charset);
+  desc = iconv_open (INTERMEDIATE_ENCODING, charset);
   if (desc == (iconv_t) -1)
     perror_with_name ("Converting character sets");
 
diff --git a/gdb/config.in b/gdb/config.in
index 0d5effa..ab0c840 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -70,6 +70,9 @@
 /* Define to 1 if you have the <bp-sym.h> header file. */
 #undef HAVE_BP_SYM_H
 
+/* Define to 1 if you have the `btowc' function. */
+#undef HAVE_BTOWC
+
 /* Define to 1 if you have the `canonicalize_file_name' function. */
 #undef HAVE_CANONICALIZE_FILE_NAME
 
diff --git a/gdb/configure b/gdb/configure
index 51f35f5..e06a451 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -15776,10 +15776,11 @@ fi
 
 
 
+
 for ac_func in canonicalize_file_name realpath getrusage getuid \
                 getgid poll pread64 sbrk setpgid setpgrp setsid \
 		sigaction sigprocmask sigsetmask socketpair syscall \
-		ttrace wborder setlocale iconvlist libiconvlist
+		ttrace wborder setlocale iconvlist libiconvlist btowc
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 821dffe..88bd8a6 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -796,7 +796,7 @@ AC_FUNC_VFORK
 AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid \
                 getgid poll pread64 sbrk setpgid setpgrp setsid \
 		sigaction sigprocmask sigsetmask socketpair syscall \
-		ttrace wborder setlocale iconvlist libiconvlist])
+		ttrace wborder setlocale iconvlist libiconvlist btowc])
 AM_LANGINFO_CODESET
 
 # Check the return and argument types of ptrace.  No canned test for
diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h
index 583140e..07a6c87 100644
--- a/gdb/gdb_wchar.h
+++ b/gdb/gdb_wchar.h
@@ -19,13 +19,36 @@
 #ifndef GDB_WCHAR_H
 #define GDB_WCHAR_H
 
-/* If this host has wchar_t and if iconv is available (perhaps via GNU
-   libiconv), then we arrange to use those.  Otherwise, we provide a
-   phony iconv which only handles a single character set, and we
-   provide wrappers for the wchar_t functionality we use.  */
-#if defined(HAVE_ICONV) && defined(HAVE_WCHAR_H)
-
+/* We handle three different modes here.
+   
+   Capable systems have the full suite: wchar_t support and iconv
+   (perhaps via GNU libiconv).  On these machines, full functionality
+   is available.
+   
+   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.
+   
+   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.  */
+
+
+#define INTERMEDIATE_ENCODING "wchar_t"
+
+#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.  */
+#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)
+
 #include <wchar.h>
 #include <wctype.h>
 
@@ -53,10 +76,15 @@ typedef int gdb_wint_t;
 
 #define LCST(X) X
 
-/* This define is used elsewhere so we don't need to duplicate the
-   same checking logic in multiple places.  */
-#define PHONY_ICONV
+/* If we are using the narrow character set, we want to use the host
+   narrow encoding as our intermediate encoding.  However, if we are
+   also providing a phony iconv, we might as well just stick with
+   "wchar_t".  */
+#ifndef PHONY_ICONV
+#undef INTERMEDIATE_ENCODING
+#define INTERMEDIATE_ENCODING host_charset ()
+#endif
 
-#endif /* defined(HAVE_ICONV) && defined(HAVE_WCHAR_H) */
+#endif
 
 #endif /* GDB_WCHAR_H */


  reply	other threads:[~2009-04-13 17:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-11 17:53 Eli Zaretskii
2009-04-13 17:54 ` Tom Tromey [this message]
2009-04-14 12:03   ` Eli Zaretskii
2009-04-14 16:31     ` Tom Tromey
2009-04-14 17:11       ` Eli Zaretskii
2009-04-14 17:42         ` Tom Tromey
2009-04-14 18:04           ` Eli Zaretskii
2009-04-14 18:15             ` Tom Tromey
2009-04-14 20:17               ` Eli Zaretskii
2009-04-15  0:23                 ` Tom Tromey
2009-04-15 10:06                   ` Eli Zaretskii
2009-04-15 14:01                     ` Eli Zaretskii
2009-04-15 15:14                       ` Tom Tromey
2009-04-15 15:33                         ` Eli Zaretskii
2009-04-15 18:04                           ` Tom Tromey
2009-04-15 19:20                             ` Eli Zaretskii
2009-04-15 19:53                               ` Tom Tromey
2009-04-15 20:18                                 ` Eli Zaretskii
2009-04-18  9:47                                   ` Eli Zaretskii
2009-04-18 17:28                                     ` Tom Tromey
2009-04-19 18:30                                       ` Eli Zaretskii
2009-04-15 15:08                     ` Tom Tromey
2009-04-15 15:12                       ` Pedro Alves
2009-04-15 15:26                         ` Tom Tromey
2009-04-15 15:47                       ` Eli Zaretskii
2009-04-15 18:07                         ` Tom Tromey
2009-04-15 22:13                   ` Tom Tromey
2009-04-18 11:05       ` Eli Zaretskii
2009-04-18 17:34         ` Tom Tromey
2009-04-18 20:56           ` Eli Zaretskii

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=m3tz4smocb.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    /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