From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13162 invoked by alias); 4 Jan 2016 06:26:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37501 Received: (qmail 27026 invoked from network); 4 Jan 2016 06:26:27 -0000 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: Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: Printf builtin missing v flag support From: "Jun T." In-Reply-To: <160102135438.ZM12227@torch.brasslantern.com> Date: Mon, 4 Jan 2016 14:50:48 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: <4C225162-CBC2-4810-ACB4-A4DBCF00A8D1@kba.biglobe.ne.jp> References: <068ca8f5-315b-444c-b281-5f183e1daa8c@email.android.com> <151231104858.ZM24513@torch.brasslantern.com> <160101135224.ZM10746@torch.brasslantern.com> <160101201724.ZM1844@torch.brasslantern.com> <160102134237.ZM17072@torch.brasslantern.com> <160102135438.ZM12227@torch.brasslantern.com> To: "zsh-workers@zsh.org" X-Mailer: Apple Mail (2.1510) X-Biglobe-Spnum: 63359 On Mac OS X (where open_memstream() does not exist), B03print.ztst fails as follows. *** 1,2 **** once more ! into-the-breach- --- 1,2 ---- once more !=20 Test ./B03print.ztst failed: output differs from expected as shown above = for: unset foo print -v foo once more print -r -- $foo printf -v foo "%s-" into the breach print -r -- $foo Error output: (eval):printf:4: i/o error: inappropriate ioctl for device Was testing: print and printf into a variable A patch is attached below. fread() returns the number of elements (items) successfully read. rcount++ for the trailing NULL. diff --git a/Src/builtin.c b/Src/builtin.c index 04d8f11..03fefa6 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -4879,10 +4879,10 @@ bin_print(char *name, char **args, Options ops, = int func) #else rewind(fout); buf =3D (char *)zalloc(count + 1); - rcount =3D fread(buf, count, 1, fout); + rcount =3D fread(buf, 1, count, fout); if (rcount < count) zwarnnam(name, "i/o error: %e", errno); - buf[rcount] =3D '\0'; + buf[rcount++] =3D '\0'; #endif queue_signals(); stringval =3D metafy(buf, rcount - 1, META_REALLOC);