This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA-v3] Handle cygwin wchar_t specifics
- From: "Pierre Muller" <pierre dot muller at ics-cnrs dot unistra dot fr>
- To: "'Eli Zaretskii'" <eliz at gnu dot org>
- Cc: <jan dot kratochvil at redhat dot com>, <tromey at redhat dot com>, <gdb-patches at sourceware dot org>
- Date: Mon, 18 Apr 2011 17:14:12 +0200
- Subject: [RFA-v3] Handle cygwin wchar_t specifics
- References: <5928.31498147479$1302882967@news.gmane.org> <m3ei53cres.fsf@fleche.redhat.com> <005101cbfc50$193136b0$4b93a410$%muller@ics-cnrs.unistra.fr> <20110416162455.GA5599@host1.jankratochvil.net> <000001cbfc7d$3f67f440$be37dcc0$%muller@ics-cnrs.unistra.fr> <83zknpoacd.fsf@gnu.org>
Here is a new version of my patch that should only
change something for Windows-OS hosts.
This patch also changes the intermediate_encoding for mingw hosts,
from "wchar_t" to "UTF-16LE", but this seems to work nicely
for both mingw32 and mingw64 (and only if iconv is found,
otherwise gdb_wchar_t is simply char and phony functions are used).
The change might nevertheless be restricted to __CYGWIN__ only
if you think that this is a better option.
Comments?
Pierre
2011-04-16 Pierre Muller <muller@ics.u-strasbg.fr>
Correct INTERMEDIATE_ENCODING macro setup for Windows OS using
2 byte "wchar_t" type.
* gdb_wchar.h (DEFAULT_INTERMEDIATE_ENCODING): New macro.
(INTERMEDIATE_ENCODING): Change macro value to...
(intermediate_encoding): New external.
* charset.c (intermediate_encoding): New variable.
(_initialize_charset): Assign default value of intermediate_encoding
using DEFAULT_INTERMEDAIT_ENCODING. Override this for
Windows OS system if size of "gdb_wchar_t" type is two.
Index: gdb_wchar.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_wchar.h,v
retrieving revision 1.6
diff -u -p -r1.6 gdb_wchar.h
--- gdb_wchar.h 1 Jan 2011 15:33:05 -0000 1.6
+++ gdb_wchar.h 18 Apr 2011 15:07:03 -0000
@@ -79,12 +79,12 @@ typedef wint_t gdb_wint_t;
hosts that emit a BOM when the unadorned name is used. */
#if defined (__STDC_ISO_10646__)
#if WORDS_BIGENDIAN
-#define INTERMEDIATE_ENCODING "UCS-4BE"
+#define DEFAULT_INTERMEDIATE_ENCODING "UCS-4BE"
#else
-#define INTERMEDIATE_ENCODING "UCS-4LE"
+#define DEFAULT_INTERMEDIATE_ENCODING "UCS-4LE"
#endif
#elif defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x108
-#define INTERMEDIATE_ENCODING "wchar_t"
+#define DEFAULT_INTERMEDIATE_ENCODING "wchar_t"
#else
/* This shouldn't happen, because the earlier #if should have filtered
out this case. */
@@ -115,11 +115,14 @@ typedef int gdb_wint_t;
also providing a phony iconv, we might as well just stick with
"wchar_t". */
#ifdef PHONY_ICONV
-#define INTERMEDIATE_ENCODING "wchar_t"
+#define DEFAULT_INTERMEDIATE_ENCODING "wchar_t"
#else
-#define INTERMEDIATE_ENCODING host_charset ()
+#define DEFAULT_INTERMEDIATE_ENCODING host_charset ()
#endif
#endif
+#define INTERMEDIATE_ENCODING intermediate_encoding
+extern const char *intermediate_encoding;
+
#endif /* GDB_WCHAR_H */
Index: charset.c
===================================================================
RCS file: /cvs/src/src/gdb/charset.c,v
retrieving revision 1.43
diff -u -p -r1.43 charset.c
--- charset.c 11 Jan 2011 15:10:01 -0000 1.43
+++ charset.c 18 Apr 2011 15:07:03 -0000
@@ -206,6 +206,7 @@ phony_iconv (iconv_t utf_flag, const cha
#define GDB_DEFAULT_TARGET_WIDE_CHARSET "UTF-32"
#endif
+const char *intermediate_encoding = NULL;
static const char *auto_host_charset_name = GDB_DEFAULT_HOST_CHARSET;
static const char *host_charset_name = "auto";
static void
@@ -935,7 +936,7 @@ _initialize_charset (void)
charset_enum = default_charset_names;
#ifndef PHONY_ICONV
-#ifdef HAVE_LANGINFO_CODESET
+# ifdef HAVE_LANGINFO_CODESET
/* The result of nl_langinfo may be overwritten later. This may
leak a little memory, if the user later changes the host charset,
but that doesn't matter much. */
@@ -946,7 +947,7 @@ _initialize_charset (void)
if (!strcmp (auto_host_charset_name, "646") || !*auto_host_charset_name)
auto_host_charset_name = "ASCII";
auto_target_charset_name = auto_host_charset_name;
-#elif defined (USE_WIN32API)
+# elif defined (USE_WIN32API)
{
/* "CP" + x<=5 digits + paranoia. */
static char w32_host_default_charset[16];
@@ -956,8 +957,14 @@ _initialize_charset (void)
auto_host_charset_name = w32_host_default_charset;
auto_target_charset_name = auto_host_charset_name;
}
+# endif
#endif
-#endif
+
+ intermediate_encoding = DEFAULT_INTERMEDIATE_ENCODING;
+# if defined (USE_WIN32API) || defined (__CYGWIN__)
+ if (sizeof (gdb_wchar_t) == 2)
+ intermediate_encoding = "UTF-16LE";
+# endif
add_setshow_enum_cmd ("charset", class_support,
charset_enum, &host_charset_name, _("\