Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	autolearn_force=no version=3.4.0
X-Biglobe-Sender: <takimoto-j@kba.biglobe.ne.jp>
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\))
Subject: Re: PATCH: refactor memstream for "print -v"
From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
In-Reply-To: <160106133012.ZM9614@torch.brasslantern.com>
Date: Fri, 8 Jan 2016 21:32:53 +0900
Content-Transfer-Encoding: quoted-printable
Message-Id: <D151E1D6-C1CB-4BA9-BE26-3609193B6235@kba.biglobe.ne.jp>
References: <160104231830.ZM20279@torch.brasslantern.com>  <4052A17B-0432-44A7-8A84-F615FD836FCF@kba.biglobe.ne.jp>  <160105095834.ZM3834@torch.brasslantern.com>  <DB99E1C4-5B22-4CDF-8C3D-982A4E037AA3@kba.biglobe.ne.jp> <160106133012.ZM9614@torch.brasslantern.com>
To: zsh-workers@zsh.org
X-Mailer: Apple Mail (2.1878.6)
X-Biglobe-Spnum: 59454
X-Seq: zsh-workers 37516


2016/01/07 06:30, Bart Schaefer <schaefer@brasslantern.com> wrote:

> I suppose that this:
>=20
>    ((COUNT =3D fread(BUF, 1, count, FOUT)) =3D=3D count)
>=20
> could correctly be replaced with
>=20
>    (count =3D=3D (count =3D fread(BUF, 1, count, FOUT)))

So you want to save the return value of fread() for debugging purpose?
I coundn't think of such a possibility.

The macro seems to work on OSX, but clang gives the following warning:

builtin.c:4435:36: warning: unsequenced modification and access to =
'count' [-Wunsequenced]
        if (IS_MSTREAM(fout) && (rcount =3D READ_MSTREAM(buf,fout)) =3D=3D=
 -1)
                                          ^~~~~~~~~~~~~~~~~~~~~~
builtin.c:4066:15: note: expanded from macro 'READ_MSTREAM'
      ((count =3D fread(BUF, 1, count, FOUT)) =3D=3D count)) ? count : =
(size_t)-1)
              ^                                ~~~~~

Anyway, I feel the macro is too complicated, so how about either

(a) revert to the original READ_MSTREAM (with (size_t)-1)
(b) give up saving the return value of fread()
   ( .... && (count =3D=3D fread(BUF, 1, count ,FOUT))) ? count : =
(size_t)-1 )
(c) write a function (not a macro) read_mstream()

Sorry for taking your time.=

