X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Tue, 6 Apr 2010 10:04:16 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: bug in btowc(0) Message-ID: <20100406080416.GO18530@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <4BBA68DF DOT 1070700 AT redhat DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4BBA68DF.1070700@redhat.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Apr 5 16:49, Eric Blake wrote: > On the gnulib list, it was pointed out that cygwin btowc has a bug: > > +#include > +#include > +#include > +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