This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: gnulib's errno module was imported
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <yao at codesourcery dot com>
- Cc: gdb-patches at sourceware dot org, gregory dot 0xf0 at gmail dot com, Joel Brobecker <brobecker at adacore dot com>
- Date: Fri, 14 Nov 2014 13:21:01 +0000
- Subject: Re: gnulib's errno module was imported
- Authentication-results: sourceware.org; auth=none
- References: <87oasaibe6 dot fsf at codesourcery dot com> <5465EBAD dot 3070108 at redhat dot com> <87fvdmhr5o dot fsf at codesourcery dot com>
On 11/14/2014 01:01 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
>
>> I think this will keep haunting and blocking us until we fix it.
>>
>
> Let us try again to fix it.
>
>> Can we reevaluate this?
>
> Sure.
>
>> 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 systems GNU iconv returns ENOENT instead.
>>
>> With that rationale, how about we try something like this?
>
> I am fine with your approach, but I am wondering why don't we simply
> check ENOENT in the places where we check EILSEQ?
>
> @@ -513,6 +513,7 @@ convert_between_encodings (const char *from, const char *to,
> switch (errno)
> {
> case EILSEQ:
> + case ENOENT:
> {
> int i;
>
> @@ -651,6 +652,7 @@ wchar_iterate (struct wchar_iterator *iter,
> switch (errno)
> {
> case EILSEQ:
> + case ENOENT:
> /* Invalid input sequence. We still might have
> converted a character; if so, return it. */
> if (out_avail < out_request * sizeof (gdb_wchar_t))
>
> This looks cleaner to me (some comments should be added, of course).
That was actually my first approach, but then:
- I thought that having a central place to handle this
and to put the comment was cleaner than repeating the fix
in multiple places.
- That won't build on systems that EILSEQ and ENOENT are
defined to the same value (two switch cases with the same value).
Not sure there are any such systems, but given iconv.h's practice...
I guess I could also simplify and remove the GNULIB_defined_EILSEQ
guard, mapping ENOENT to EILSEQ everywhere ?
+/* On systems that don't have EILSEQ, GNU iconv's iconv.h defines it
+ to ENOENT. gnulib instead defines it to a different value. On
+ such systems, map ENOENT to gnulib's EILSEQ, leaving callers
+ agnostic. */
+#ifdef GNULIB_defined_EILSEQ
I looked at glibc's iconv and it seems that ENOENT is never used
there, so should be safe.
Thanks,
Pedro Alves