Marco Cimarosti <[EMAIL PROTECTED]>:
> BTW, I see that Plauger's reference contradicts what Markus said in two
> points, and I have no way of determining who is more correct or up to date:
>
> 1) In <http://www.dinkumware.com/htm_cl/wchar.html#mbrtowc>, it says that
> mbrtowc() return zero only when "the next completed character is a null
> character", which cannot of course be the case when the size is zero.
> Plauger too does not specify what the function should return in this case,
> but -2 ("incomplete mb character") seems a reasonable choice.
It's the only reasonable choice, even if you can argue,
legalistically, that according to some standard mbrtowc is entitled to
return -42 and randomly corrupt memory when given size = 0.
> 2) In <http://www.dinkumware.com/htm_cl/wchar.html#mbstate_t> it says that
> mbstate_t can be initialized simply by setting its *first* member of to
> zero ("mbstate_t mbst = {0};"), and this would imply that a memset() is only
> needed to *re*initialize it.
I don't think you are allowed to assume that mbstate_t is a structure
and has members, so memset is definitely better.
Edmund
-
Linux-UTF8: i18n of Linux on all levels
Archive: http://mail.nl.linux.org/linux-utf8/