public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Introduce the 'usertemp' filesystem type
Date: Thu, 22 Oct 2015 12:45:00 -0000	[thread overview]
Message-ID: <20151022124547.GA5319@calimero.vinschen.de> (raw)
In-Reply-To: <20151021182346.GE17374@calimero.vinschen.de>

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

  reply	other threads:[~2015-10-22 12:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16  7:35 Johannes Schindelin
2015-10-20  9:37 ` Corinna Vinschen
2015-10-20 11:47   ` Johannes Schindelin
2015-10-21 18:23     ` Corinna Vinschen
2015-10-22 12:45       ` Corinna Vinschen [this message]
2015-10-22 15:31       ` Johannes Schindelin
2015-12-01 14:02 ` [PATCH v2] " Johannes Schindelin
2015-12-01 14:12   ` Johannes Schindelin
2015-12-01 14:27   ` Corinna Vinschen
2015-12-01 14:50     ` Johannes Schindelin
2015-12-07 16:42       ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151022124547.GA5319@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).