[PATCH] Introduce the 'usertemp' filesystem type
Corinna Vinschen
corinna-cygwin@cygwin.com
Thu Oct 22 12:45:00 GMT 2015
On Oct 21 20:23, Corinna Vinschen wrote:
> On Oct 20 13:47, Johannes Schindelin wrote:
> > On Tue, 20 Oct 2015, Corinna Vinschen wrote:
> > > On Sep 16 09:35, Johannes Schindelin wrote:
> > [...]
> > > > + char mb_tmp[len = sys_wcstombs (NULL, 0, tmp)];
> > >
> > > - len = sys_wcstombs() + 1
> >
> > Whoops. I always get that wrong.
> >
> > But... actually... Did you know that `sys_wcstombs()` returns something
> > different than advertised? The documentation says:
> >
> > - dst == NULL; len is ignored, the return value is the number
> > of bytes required for the string without the trailing NUL, just
> > like the return value of the wcstombs function.
> >
> > But when I call
> >
> > small_printf("len of 1: %d\n", sys_wcstombs(NULL, 0, L"1"));
> >
> > it prints "len of 1: 2", i.e. the number of bytes requires for the string
> > *with* the trailing NUL, disagreeing with the comment in strfuncs.cc.
>
> Drat. You're right. As usual I wonder why nobody ever noticed this.
> As soon as the nwc parameter is larger than the number of non-0 wchars
> in the source string, sys_cp_wcstombs returns the length including the
> trailing NUL.
>
> And looking through the Cygwin sources the usage is rather erratic,
> sometimes with, sometimes without + 1 :(
>
> > How do you want to proceed from here? Should I fix sys_wcstombs() when the
> > fourth parameter is -1? Or is this not a fix, but I would rather break
> > things?
>
> No, this needs fixing, but it also would break things. I have to take
> a stab at fixing this throughout Cygwin first.
I just pushed a patch to the git repo supposed to fix sys_cp_wcstombs
return value inconsistency. It should now always return the length of
the string without the trailing NUL. Please give it a try.
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
More information about the Cygwin-patches
mailing list