This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: [PATCH] Introduce the 'usertemp' filesystem type
- From: Corinna Vinschen <corinna-cygwin at cygwin dot com>
- To: cygwin-patches at cygwin dot com
- Date: Thu, 22 Oct 2015 14:45:47 +0200
- Subject: Re: [PATCH] Introduce the 'usertemp' filesystem type
- Authentication-results: sourceware.org; auth=none
- References: <0MIuft-1ZZdDB2IaP-002Y2r at mail dot gmx dot com> <20151020093741 dot GA17374 at calimero dot vinschen dot de> <alpine dot DEB dot 1 dot 00 dot 1510201251140 dot 31610 at s15462909 dot onlinehome-server dot info> <20151021182346 dot GE17374 at calimero dot vinschen dot de>
- Reply-to: cygwin-patches at cygwin dot com
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