Markus Kuhn <[EMAIL PROTECTED]>:

> > With glibc-2.2.3, mbrtowc(&wc, "", 0, &ps) seems to return 0 instead
> > of (size_t)(-2). I think this is a bug.
> 
> It is a bug in your software. You should never call mbrtowc with 0 as
> the number n of bytes that mbrtowc is allowed to examine at most. Such a
> call seems useless, and the standard does not define the behaviour of
> mbrtowc in that case.
> 
> One could argue - and I probably would agree - that (size_t)(-2) might
> be an aesthetically more pleasing return value in that situation, but
> that is not really a requirement of ISO/IEC 9899:1999(E), �7.24.6.3.2 on
> page 388.

I don't have that document. Could you quote the bit that says that n
musn't be zero?

> Perhaps someone should write a tutorial on common pitfalls with the
> restartable multi-byte functions.

A list of common mistakes would certainly be helpful, but the priority
should be to provide correct man pages. The man page I looked at said
nothing about n not being zero, so I assumed I didn't have to check n
myself. The code in question is for boot floppies, so I deliberately
avoid performing unnecessary checks, which, in another application, I
might be happy to do "for safety".

Edmund
-
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to