From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: "'Eli Zaretskii'" <eliz@gnu.org>
Cc: <jan.kratochvil@redhat.com>, <tromey@redhat.com>,
<gdb-patches@sourceware.org>
Subject: [RFA-v3] Handle cygwin wchar_t specifics
Date: Mon, 18 Apr 2011 15:14:00 -0000 [thread overview]
Message-ID: <00df01cbfddb$468f4250$d3adc6f0$@muller@ics-cnrs.unistra.fr> (raw)
In-Reply-To: <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, _("\
next prev parent reply other threads:[~2011-04-18 15:14 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5928.31498147479$1302882967@news.gmane.org>
2011-04-15 18:16 ` [RFA] " Tom Tromey
2011-04-16 16:05 ` Pierre Muller
2011-04-16 16:25 ` Jan Kratochvil
2011-04-16 21:29 ` [RFA-v2] " Pierre Muller
2011-04-16 22:35 ` Jan Kratochvil
[not found] ` <000001cbfc7d$3f67f440$be37dcc0$%muller@ics-cnrs.unistra.fr>
2011-04-17 2:55 ` Eli Zaretskii
2011-04-18 10:36 ` Pierre Muller
[not found] ` <00a801cbfdb4$551214a0$ff363de0$%muller@ics-cnrs.unistra.fr>
2011-04-18 10:57 ` Eli Zaretskii
2011-04-18 15:14 ` Pierre Muller [this message]
[not found] ` <21014.6501930014$1303139687@news.gmane.org>
2011-04-18 17:18 ` [RFA-v3] " Tom Tromey
2011-04-19 9:18 ` [RFC-v4] " Pierre Muller
[not found] ` <004f01cbfe72$adddeb40$0999c1c0$%muller@ics-cnrs.unistra.fr>
2011-04-19 9:34 ` Eli Zaretskii
[not found] ` <34716.7311156683$1303204711@news.gmane.org>
2011-04-19 13:19 ` Tom Tromey
2011-04-19 13:56 ` [RFC-v5] " Pierre Muller
[not found] ` <16656.7281041809$1303221408@news.gmane.org>
2011-04-19 17:50 ` Tom Tromey
2011-04-20 7:59 ` Pierre Muller
2011-04-20 21:08 ` Pedro Alves
2011-04-21 6:57 ` Pierre Muller
2011-04-21 7:17 ` [RFA-v6] " Pierre Muller
2011-04-21 9:02 ` Pierre Muller
[not found] ` <24274.3825926029$1303376558@news.gmane.org>
2011-04-21 14:14 ` Tom Tromey
2011-04-21 14:27 ` Pierre Muller
[not found] ` <4691.37052209607$1303396084@news.gmane.org>
2011-04-21 15:06 ` Tom Tromey
2011-04-21 16:39 ` Pierre Muller
[not found] ` <25400.1310132027$1303403986@news.gmane.org>
2011-04-21 20:25 ` Tom Tromey
2011-04-21 21:18 ` 7.3 commit " Pierre Muller
[not found] ` <15550.7422438406$1303369059@news.gmane.org>
2011-04-21 14:10 ` [RFC-v5] " Tom Tromey
[not found] ` <420.768399681215$1303286406@news.gmane.org>
2011-04-20 20:21 ` Tom Tromey
2011-04-16 21:24 ` [RFA] " Tom Tromey
2011-04-18 20:07 ` Corinna Vinschen
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='00df01cbfddb$468f4250$d3adc6f0$@muller@ics-cnrs.unistra.fr' \
--to=pierre.muller@ics-cnrs.unistra.fr \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=tromey@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