This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gnulib's errno module was imported


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]