X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Trace-PostClient-IP: 68.147.225.57 From: Brian Inglis Newsgroups: comp.os.msdos.djgpp Subject: Re: Bug in mbstowcs() in DJGPP's C library Organization: Systematic Software Message-ID: <33k383ptj4ch90bdt8fs8jiakcjovmojef@4ax.com> References: <86pabupynhr DOT fsf AT sirppi DOT helsinki DOT fi> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 39 Date: Wed, 27 Jun 2007 03:00:26 GMT NNTP-Posting-Host: 64.59.135.176 X-Complaints-To: abuse AT shaw DOT ca X-Trace: pd7urf3no 1182913226 64.59.135.176 (Tue, 26 Jun 2007 21:00:26 MDT) NNTP-Posting-Date: Tue, 26 Jun 2007 21:00:26 MDT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com fOn 25 Jun 2007 01:52:00 +0300 in comp.os.msdos.djgpp, Esa A E Peuha wrote: >Simon Tatham writes: > >> I believe mbstowcs() in DJGPP's C library is behaving incorrectly. >> It appears to be unwilling to fill its entire output buffer with >> non-zero wide characters, preferring to stop one character short of >> the end of the buffer > >That's correct. > >> and write a NUL. > >But this isn't; from the current source > >size_t >mbstowcs(wchar_t *wcs, const char *s, size_t n) >{ > size_t i; > for (i=0; (i+1 wcs[i] = s[i]; > if (i+1 wcs[i] = 0; > return i; >} > >it's obvious that the function simply treats its numeric argument as >one less than it actually is. mbstowcs() should be using the support(ed) function mbtowc() to do wide character conversion to "do the right thing" and allow mbs and wcs support to be added to the lower level function in future. -- Thanks. Take care, Brian Inglis Calgary, Alberta, Canada Brian DOT Inglis AT CSi DOT com (Brian[dot]Inglis{at}SystematicSW[dot]ab[dot]ca) fake address use address above to reply