mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-03 04:12:10 +08:00
handle 'iconv's that define EILSEQ to ENOENT
We're currently pulling gnulib's errno module as a dependency of some other module. That provides an errno.h that defines EILSEQ to a distinct value if the system's errno.h doesn't define it already. However, GNU iconv does this: /* Get errno declaration and values. */ #include <errno.h> /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, have EILSEQ in a different header. On these systems, define EILSEQ ourselves. */ #ifndef EILSEQ #define EILSEQ @EILSEQ@ #endif That's in: http://git.savannah.gnu.org/cgit/libiconv.git/tree/include/iconv.h.in The "different header" mentioned is wchar.h. This is handled in: http://git.savannah.gnu.org/cgit/libiconv.git/tree/m4/eilseq.m4 which defines @EILSEQ@ to ENOENT if EILSEQ isn't found in either errno.h or wchar.h. So if iconv sets errno to EILSEQ on such system's, it's really setting it to ENOENT. And when we check for EILSEQ, we're checking for gnulib's value. The result is we won't detect the error correctly. As we dropped support for both SunOS 4 or old BSD/OS, maybe we don't need to care about the wchar.h issue anymore. Still, AFAICS, gnulib's m4/errno_h.m4 doesn't know that EILSEQ may be defined in wchar.h, and so on such systems, ISTM gnulib ends up defining an incompatible EILSEQ itself, but I think that should be fixed on the gnulib side, by making it extract the EILSEQ value out of the system's wchar.h, like GNU iconv does. So that leaves handling the case of gnulib making up a EILSEQ value, which we take as meaning the system really doesn't really define it, which will be the same systems GNU iconv sets errno to ENOENT instead of EILSEQ. Looking at glibc's iconv it seems that ENOENT is never used there. It seems it's safe to always treat ENOENT the same as EILSEQ. The current EILSEQ definition under PHONY_ICONV is obviously stale as gnulib garantees there's always a EILSEQ defined. Tested on x86_64 Fedora 20. gdb/ 2014-11-14 Pedro Alves <palves@redhat.com> * charset.c [PHONY_ICONV && !EILSEQ] (EILSEQ): Don't define. [!PHONY_ICONV] (gdb_iconv): New function. [!PHONY_ICONV] (iconv): Redefine to gdb_iconv.
This commit is contained in:
parent
470c009be8
commit
830301108d
@ -1,3 +1,9 @@
|
||||
2014-11-14 Pedro Alves <palves@redhat.com>
|
||||
|
||||
* charset.c [PHONY_ICONV && !EILSEQ] (EILSEQ): Don't define.
|
||||
[!PHONY_ICONV] (gdb_iconv): New function.
|
||||
[!PHONY_ICONV] (iconv): Redefine to gdb_iconv.
|
||||
|
||||
2014-11-13 Doug Evans <dje@google.com>
|
||||
|
||||
PR symtab/17591
|
||||
|
@ -95,15 +95,6 @@
|
||||
#undef ICONV_CONST
|
||||
#define ICONV_CONST const
|
||||
|
||||
/* Some systems don't have EILSEQ, so we define it here, but not as
|
||||
EINVAL, because callers of `iconv' want to distinguish EINVAL and
|
||||
EILSEQ. This is what iconv.h from libiconv does as well. Note
|
||||
that wchar.h may also define EILSEQ, so this needs to be after we
|
||||
include wchar.h, which happens in defs.h through gdb_wchar.h. */
|
||||
#ifndef EILSEQ
|
||||
#define EILSEQ ENOENT
|
||||
#endif
|
||||
|
||||
static iconv_t
|
||||
phony_iconv_open (const char *to, const char *from)
|
||||
{
|
||||
@ -187,8 +178,28 @@ phony_iconv (iconv_t utf_flag, const char **inbuf, size_t *inbytesleft,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#else /* PHONY_ICONV */
|
||||
|
||||
/* On systems that don't have EILSEQ, GNU iconv's iconv.h defines it
|
||||
to ENOENT, while gnulib defines it to a different value. Always
|
||||
map ENOENT to gnulib's EILSEQ, leaving callers agnostic. */
|
||||
|
||||
static size_t
|
||||
gdb_iconv (iconv_t utf_flag, ICONV_CONST char **inbuf, size_t *inbytesleft,
|
||||
char **outbuf, size_t *outbytesleft)
|
||||
{
|
||||
size_t ret;
|
||||
|
||||
ret = iconv (utf_flag, inbuf, inbytesleft, outbuf, outbytesleft);
|
||||
if (errno == ENOENT)
|
||||
errno = EILSEQ;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef iconv
|
||||
#define iconv gdb_iconv
|
||||
|
||||
#endif /* PHONY_ICONV */
|
||||
|
||||
|
||||
/* The global lists of character sets and translations. */
|
||||
|
Loading…
Reference in New Issue
Block a user