From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: PATCH: refactor memstream for "print -v"
Date: Wed, 6 Jan 2016 15:02:19 +0900 [thread overview]
Message-ID: <DB99E1C4-5B22-4CDF-8C3D-982A4E037AA3@kba.biglobe.ne.jp> (raw)
In-Reply-To: <160105095834.ZM3834@torch.brasslantern.com>
On 2016/01/06, at 2:58, Bart Schaefer <schaefer@brasslantern.com> wrote:
> but I was
> trying to be consistent with open_memstream() which maintains a NUL at
> the end of the buffer it manages.
Sorry, then I misunderstood what you wanted to achieve. I just thought
the simpler the better.
> Maybe it should be (long) though? And I suppose the comparison should
> explicitly be == -1 rather than < 0 in case mcount is ridiculusly big.
Yes. Moreover, if '== -1' is used, casting by (long) may not be necessary,
because if n is of type size_t,
(x ? n : -1) == -1 --> (x ? n : (size_t)-1) == (size_t)-1
is true only if x is false or n==(size_t)-1. On my Mac (and probably
on most systems) the following seems to be equivalent to the above:
(x ? (long)n : -1) == -1 --> (x ? (long)n : (long)-1) == (long)-1
but in theory signed --> unsigned is safer than unsigned --> signed.
So not casting (or using (size_t)-1) may be better?
BTW, how about modifying READ_MSTREAM so that
READ_MSTREAM(buf,rcount,fout) == -1
can be replaced by
(rcount = READ_MSTREAM(buf,fout)) == -1
or
!READ_MSTREAM(buf,rcount,fout)
next prev parent reply other threads:[~2016-01-06 6:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-05 7:18 Bart Schaefer
2016-01-05 9:48 ` Peter Stephenson
2016-01-05 11:47 ` Peter Stephenson
2016-01-05 16:33 ` Bart Schaefer
2016-01-05 16:31 ` Jun T.
2016-01-05 17:58 ` Bart Schaefer
2016-01-06 6:02 ` Jun T. [this message]
2016-01-06 21:30 ` Bart Schaefer
2016-01-08 12:32 ` Jun T.
2016-01-09 4:37 ` Bart Schaefer
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=DB99E1C4-5B22-4CDF-8C3D-982A4E037AA3@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.org \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).