Mail Archives: cygwin/2010/04/06/04:04:37
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
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -