This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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] | |
On 04/06/2010 02:04 AM, Corinna Vinschen wrote:
> On Apr 5 16:49, Eric Blake wrote:
>> On the gnulib list, it was pointed out that cygwin btowc has a bug:
>>
>> +#include <stdio.h>
>> +#include <string.h>
>> +#include <wchar.h>
>> +int main ()
>> +{
>> + if (btowc ('\0') != 0)
>> + return 1;
>> + return 0;
>> +}
>>
>> should have status 0, because NUL is an ASCII byte. Right now, btowc is
>> mistakenly returning WEOF and this program has status 1.
>
> That's a newlib problem. Please send the bug report to the newlib
> list, for the records. This patch should help:
>
> Index: libc/stdlib/btowc.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/stdlib/btowc.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 btowc.c
> --- libc/stdlib/btowc.c 18 Nov 2009 09:49:57 -0000 1.3
> +++ libc/stdlib/btowc.c 6 Apr 2010 08:02:37 -0000
> @@ -13,6 +13,9 @@ btowc (int c)
> wchar_t pwc;
> unsigned char b;
>
> + if (c == EOF)
> + return WEOF;
> +
> b = (unsigned char)c;
>
> /* Put mbs in initial state. */
> @@ -22,8 +25,8 @@ btowc (int c)
>
> retval = __mbtowc (_REENT, &pwc, &b, 1, __locale_charset (), &mbs);
>
> - if (c == EOF || retval != 1)
> + if (retval != 0 && retval != 1)
> return WEOF;
> - else
> - return (wint_t)pwc;
> +
> + return (wint_t)pwc;
> }
>
>
> Corinna
>
For what it's worth, Corinna's patch looks good to me.
--
Eric Blake eblake@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
Attachment:
signature.asc
Description: OpenPGP digital signature
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |