Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gdb-patches@sourceware.org, gregory.0xf0@gmail.com,
	       Joel Brobecker <brobecker@adacore.com>
Subject: Re: gnulib's errno module was imported
Date: Fri, 14 Nov 2014 13:21:00 -0000	[thread overview]
Message-ID: <546601BD.7020700@redhat.com> (raw)
In-Reply-To: <87fvdmhr5o.fsf@codesourcery.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


  reply	other threads:[~2014-11-14 13:21 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-14  5:45 Yao Qi
2014-11-14  7:33 ` Eli Zaretskii
2014-11-14  8:30   ` Yao Qi
2014-11-14  8:44     ` Gregory Fong
2014-11-14  9:26     ` Eli Zaretskii
2014-11-14 11:29 ` Joel Brobecker
2014-11-14 11:47 ` Pedro Alves
2014-11-14 13:02   ` Yao Qi
2014-11-14 13:21     ` Pedro Alves [this message]
2014-11-14 13:54       ` Yao Qi
2014-11-14 14:39         ` Pedro Alves
2014-11-14 15:18           ` Joel Brobecker
2014-11-14 16:01             ` Pedro Alves
2014-11-14 23:08               ` Yao Qi
2014-11-14 14:31       ` Eli Zaretskii
2014-11-14 14:42         ` Pedro Alves

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=546601BD.7020700@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=gregory.0xf0@gmail.com \
    --cc=yao@codesourcery.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