mbstowcs() contradiction

Jilles Tjoelker jilles at stack.nl
Mon Jun 1 23:09:18 UTC 2009


On Mon, Jun 01, 2009 at 11:51:54PM +0200, Gabor Kovesdan wrote:
> I've just found a contradiction in the mbstowcs() man page. It says:
> "The mbstowcs() function returns ........  or -1 if an invalid multibyte 
> character was encountered."

> It is impossible, because its return value is size_t, which is a signed 
> type. Looking on the online documentaton, I think it should return 
> (size_t)-1 on error. I've also looked at the code and I think our 
> implementation is standard-compliant, but could someone take another 
> look, please? If someone can acknowledge I'm right, I'll update the man 
> page.

Apart from the fact that size_t is an unsigned type, that is correct.
The function returns (size_t)-1 on error.

On another note, the XSI extension of allowing a NULL destination
pointer to find the length seems to be implemented but is not
documented. The EILSEQ errno is also an XSI extension.

-- 
Jilles Tjoelker


More information about the freebsd-standards mailing list