On Thu, Mar 07, 2013 at 09:40:40AM -0800, Philip Guenther wrote:
> On Thu, Mar 7, 2013 at 8:36 AM, Stefan Sperling <[email protected]> wrote:
> > On Thu, Mar 07, 2013 at 10:51:13AM -0500, Vladimir Támara Patiño wrote:
> >> Working on collations again (based on FreeBSD implementation) and
> >> reading "wcrtomb" I see that return value of wcrtomb should be
> >> either positive or (size_t)-1, then:
> ...
> >> --- src53orig/lib/libc/citrus/citrus_none.c     Sat Feb  9 14:26:51 2013
> >> +++ src53coll/lib/libc/citrus/citrus_none.c     Sat Mar  2 06:59:58 2013
> >> @@ -115,7 +115,7 @@
> >> /* ps appears to be unused */
> >>
> >>       if (s == NULL)
> >> -               return (0);
> >> +               return (1);
> >
> > It's perfectly fine to return zero according to
> > http://pubs.opengroup.org/onlinepubs/009695399/functions/wcrtomb.html
> >   "The wcrtomb() function shall return the number of bytes stored in the
> >   array object (including any shift sequences)."
> 
> Ah, but that has to be read in light of the description section, which says:
> 
>     If s is a null pointer, the wcrtomb() function shall be equivalent
> to the call:
> 
>     wcrtomb(buf, L'\0', ps)
> 
>     where buf is an internal buffer.
> 
> Since that call returns 1 when you pass in a buffer of your own,
> wcrtomb(NULL, whatever, ps) should return 1 too.
> 
> 
> Philip Guenther

Right. Thanks for pointing that out.
In fact, the UTF-8 implementation also returns 1 in this case.
So I'm fine with Vladimir's change.

Reply via email to