* charset.c (iconv_open): New define.
(iconv): Likewise. (iconv_close): Likewise. (phony_iconv_open): Add "phony_" prefix. (phony_iconv_close): Likewise. (phony_iconv): Likewise. * gdb_wchar.h: Check _LIBICONV_VERSION, __STDC_ISO_10646__. Change how INTERMEDIATE_ENCODING is defined.
This commit is contained in:
parent
d3fe237dc1
commit
62234ccc1e
|
@ -1,3 +1,14 @@
|
||||||
|
2010-09-15 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
|
* charset.c (iconv_open): New define.
|
||||||
|
(iconv): Likewise.
|
||||||
|
(iconv_close): Likewise.
|
||||||
|
(phony_iconv_open): Add "phony_" prefix.
|
||||||
|
(phony_iconv_close): Likewise.
|
||||||
|
(phony_iconv): Likewise.
|
||||||
|
* gdb_wchar.h: Check _LIBICONV_VERSION, __STDC_ISO_10646__.
|
||||||
|
Change how INTERMEDIATE_ENCODING is defined.
|
||||||
|
|
||||||
2010-09-15 Doug Evans <dje@google.com>
|
2010-09-15 Doug Evans <dje@google.com>
|
||||||
|
|
||||||
* dwarf2read.c (struct die_info): Fix comment.
|
* dwarf2read.c (struct die_info): Fix comment.
|
||||||
|
|
|
@ -90,8 +90,11 @@
|
||||||
#undef iconv_t
|
#undef iconv_t
|
||||||
#define iconv_t int
|
#define iconv_t int
|
||||||
#undef iconv_open
|
#undef iconv_open
|
||||||
|
#define iconv_open phony_iconv_open
|
||||||
#undef iconv
|
#undef iconv
|
||||||
|
#define iconv phony_iconv
|
||||||
#undef iconv_close
|
#undef iconv_close
|
||||||
|
#define iconv_close phony_iconv_close
|
||||||
|
|
||||||
#undef ICONV_CONST
|
#undef ICONV_CONST
|
||||||
#define ICONV_CONST const
|
#define ICONV_CONST const
|
||||||
|
@ -106,7 +109,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
iconv_t
|
iconv_t
|
||||||
iconv_open (const char *to, const char *from)
|
phony_iconv_open (const char *to, const char *from)
|
||||||
{
|
{
|
||||||
/* We allow conversions from UTF-32BE, wchar_t, and the host charset.
|
/* We allow conversions from UTF-32BE, wchar_t, and the host charset.
|
||||||
We allow conversions to wchar_t and the host charset. */
|
We allow conversions to wchar_t and the host charset. */
|
||||||
|
@ -122,14 +125,14 @@ iconv_open (const char *to, const char *from)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
iconv_close (iconv_t arg)
|
phony_iconv_close (iconv_t arg)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
iconv (iconv_t utf_flag, const char **inbuf, size_t *inbytesleft,
|
phony_iconv (iconv_t utf_flag, const char **inbuf, size_t *inbytesleft,
|
||||||
char **outbuf, size_t *outbytesleft)
|
char **outbuf, size_t *outbytesleft)
|
||||||
{
|
{
|
||||||
if (utf_flag)
|
if (utf_flag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,20 +23,24 @@
|
||||||
|
|
||||||
Capable systems have the full suite: wchar_t support and iconv
|
Capable systems have the full suite: wchar_t support and iconv
|
||||||
(perhaps via GNU libiconv). On these machines, full functionality
|
(perhaps via GNU libiconv). On these machines, full functionality
|
||||||
is available.
|
is available. Note that full functionality is dependent on us
|
||||||
|
being able to convert from an arbitrary encoding to wchar_t. In
|
||||||
|
practice this means we look for __STDC_ISO_10646__ (where we know
|
||||||
|
the name of the wchar_t encoding) or GNU libiconv, where we can use
|
||||||
|
"wchar_t".
|
||||||
|
|
||||||
DJGPP is known to have libiconv but not wchar_t support. On
|
DJGPP is known to have libiconv but not wchar_t support. On
|
||||||
systems like this, we use the narrow character functions. The full
|
systems like this, we use the narrow character functions. The full
|
||||||
functionality is available to the user, but many characters (those
|
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.
|
||||||
|
|
||||||
Finally, some systems do not have iconv. Here we provide a phony
|
Finally, some systems do not have iconv, or are really broken
|
||||||
iconv which only handles a single character set, and we provide
|
(e.g., Solaris, which almost has all of this working, but where
|
||||||
wrappers for the wchar_t functionality we use. */
|
just enough is broken to make it too hard to use). 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)
|
#if defined (HAVE_ICONV)
|
||||||
#include <iconv.h>
|
#include <iconv.h>
|
||||||
#else
|
#else
|
||||||
|
@ -45,9 +49,15 @@
|
||||||
#define PHONY_ICONV
|
#define PHONY_ICONV
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We use "btowc" as a sentinel to detect functioning wchar_t
|
/* We use "btowc" as a sentinel to detect functioning wchar_t support.
|
||||||
support. */
|
We check for either __STDC_ISO_10646__ or a new-enough libiconv in
|
||||||
#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC)
|
order to ensure we can convert to and from wchar_t. We choose
|
||||||
|
libiconv version 0x10D because it was reported that earlier
|
||||||
|
versions do not always accept "wchar_t" as an encoding
|
||||||
|
argument. */
|
||||||
|
#if defined (HAVE_ICONV) && defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC) \
|
||||||
|
&& (defined (__STDC_ISO_10646__) \
|
||||||
|
|| (defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x10D))
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
#include <wctype.h>
|
#include <wctype.h>
|
||||||
|
@ -63,7 +73,32 @@ typedef wint_t gdb_wint_t;
|
||||||
|
|
||||||
#define LCST(X) L ## X
|
#define LCST(X) L ## X
|
||||||
|
|
||||||
|
/* If __STDC_ISO_10646__ is defined, then the host wchar_t is UCS-4.
|
||||||
|
We exploit this fact in the hope that there are hosts that define
|
||||||
|
this but which do not support "wchar_t" as an encoding argument to
|
||||||
|
iconv_open. We put the endianness into the encoding name to avoid
|
||||||
|
hosts that emit a BOM when the unadorned name is used. */
|
||||||
|
#if defined (__STDC_ISO_10646__)
|
||||||
|
#if WORDS_BIGENDIAN
|
||||||
|
#define INTERMEDIATE_ENCODING "UCS-4BE"
|
||||||
#else
|
#else
|
||||||
|
#define INTERMEDIATE_ENCODING "UCS-4LE"
|
||||||
|
#endif
|
||||||
|
#elif defined (_LIBICONV_VERSION) && _LIBICONV_VERSION >= 0x10D
|
||||||
|
#define INTERMEDIATE_ENCODING "wchar_t"
|
||||||
|
#else
|
||||||
|
/* This shouldn't happen, because the earlier #if should have filtered
|
||||||
|
out this case. */
|
||||||
|
#error "Neither __STDC_ISO_10646__ nor _LIBICONV_VERSION defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* If we got here and have wchar_t support, we might be on a system
|
||||||
|
with some problem. So, we just disable everything. */
|
||||||
|
#if defined (HAVE_WCHAR_H) && defined (HAVE_BTOWC)
|
||||||
|
#define PHONY_ICONV
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef char gdb_wchar_t;
|
typedef char gdb_wchar_t;
|
||||||
typedef int gdb_wint_t;
|
typedef int gdb_wint_t;
|
||||||
|
@ -80,8 +115,9 @@ typedef int gdb_wint_t;
|
||||||
narrow encoding as our intermediate encoding. However, if we are
|
narrow encoding as our intermediate encoding. However, if we are
|
||||||
also providing a phony iconv, we might as well just stick with
|
also providing a phony iconv, we might as well just stick with
|
||||||
"wchar_t". */
|
"wchar_t". */
|
||||||
#ifndef PHONY_ICONV
|
#ifdef PHONY_ICONV
|
||||||
#undef INTERMEDIATE_ENCODING
|
#define INTERMEDIATE_ENCODING "wchar_t"
|
||||||
|
#else
|
||||||
#define INTERMEDIATE_ENCODING host_charset ()
|
#define INTERMEDIATE_ENCODING host_charset ()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue