From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23000 invoked by alias); 18 Apr 2011 15:14:40 -0000 Received: (qmail 22990 invoked by uid 22791); 18 Apr 2011 15:14:38 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.154) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Apr 2011 15:14:23 +0000 Received: from md2.u-strasbg.fr (md2.u-strasbg.fr [IPv6:2001:660:2402::187]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id p3IFEDBx056366 ; Mon, 18 Apr 2011 17:14:13 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms4.u-strasbg.fr [130.79.204.13]) by md2.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p3IFECdM010912 ; Mon, 18 Apr 2011 17:14:12 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p3IFEBFc031370 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Mon, 18 Apr 2011 17:14:12 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Eli Zaretskii'" Cc: , , References: <5928.31498147479$1302882967@news.gmane.org> <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> In-Reply-To: <83zknpoacd.fsf@gnu.org> Subject: [RFA-v3] Handle cygwin wchar_t specifics Date: Mon, 18 Apr 2011 15:14:00 -0000 Message-ID: <00df01cbfddb$468f4250$d3adc6f0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-04/txt/msg00275.txt.bz2 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 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, _("\