www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2007/06/24/19:00:33

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Esa A E Peuha <esa DOT peuha AT helsinki DOT fi>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bug in mbstowcs() in DJGPP's C library
Date: 25 Jun 2007 01:52:00 +0300
Organization: University of Helsinki
Lines: 31
Message-ID: <86pabupynhr.fsf@sirppi.helsinki.fi>
References: <ioF*uuQNr AT news DOT chiark DOT greenend DOT org DOT uk>
NNTP-Posting-Host: sirppi.helsinki.fi
X-Trace: oravannahka.helsinki.fi 1182725520 14176 128.214.205.27 (24 Jun 2007 22:52:00 GMT)
X-Complaints-To: abuse AT helsinki DOT fi
NNTP-Posting-Date: 24 Jun 2007 22:52:00 GMT
X-Newsreader: Gnus v5.6.43/Emacs 19.34
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Simon Tatham <anakin AT pobox DOT com> 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<n) && s[i]; i++)
    wcs[i] = s[i];
  if (i+1<n)
    wcs[i] = 0;
  return i;
}

it's obvious that the function simply treats its numeric argument as
one less than it actually is.

-- 
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019