From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25701 invoked by alias); 7 Jun 2015 20:45:42 -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: 35412 Received: (qmail 16466 invoked from network); 7 Jun 2015 20:45:38 -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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1433709565; bh=P+4PW6zLehUiXN0Qkn1skOZ2B5lzRUukaSXNc6bXCaM=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=AJuOpeCPxcV5dnwf34QFXj/L6p9EJB3w0FHvDsmkHnC92fWdJQSUmTjLoNPb00Ju42AdHSwKrth8ji2ZTSkaeIiOq2laSSBusfllVNCQG1xMi1Jtez936GANZM4VDjAw8s0AF/wOPNWU8SyMG3ELN9VMzuyeR5eZxdT+/zFS+6d6ry3pT4YNesRCh2jF2Es879NycDXnv/hg5yLR7MI4K9gBL5LhQpihI/4n5X79bruEJbs42T7koPovkMM58H74zJrGl2sDmG072nf9B9wfMdB8UPjZ1no6gixdMmdRzzS0MRPIKmdb41vOZslmX/ErM7Q6DnOa4gr6bwLxKDEGSw== X-Yahoo-Newman-Id: 284343.13685.bm@smtp145.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 56UFot0VM1nWzVM.ntt.MQTrNXo5B6iDmE_QetUpGk3XO4D CRc3d07PqWhe4_L_qeLWsZzsTzP6IbJx2AwmdTyLOF94JvRXSHyDcxeaA4FW OcRqjdeSLSHTic7z2W1bxJeYORR2FbDSPr.CGGiaGp2oG4BS4MKvyq0GFeGX 8hg8ddil.Lo8cMN9UPwWx64VX4.LtBi9qon9HRHMVD9sVnYA4JFR_L6_F43d I1u5mhLarSj6yYWBcrev1ysKbDYiY.lEBikdLhH2I8_BzUl3rOZE91wNCxgK XQ47Z02qcMKW7tYLK9jSffwHmoM3VWYdU600g2QFPoiK.IjWwxmABVKZOdNB qpQLNzSiahOWPx09yGgENl6FvFx3JJGa5jp0AmoJ2dX5an40D7VadTMAWMZG djIKwXrZovYiJ8NQeEQuZealTwQKb9YhDasfdIcvgip4.jUGGy3rwsXOaP6E 6vzSFnWg.oiWZz4CE2DIDbhlVdHTYrEnxmoBg8WKfus9h3veoE.xbhj7RJMK 8rmh_QV7FkE.MTMHoatKsYdKmyVa6.qlU X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <20150607081142.GF15174@isis.sigpipe.cz> From: Oliver Kiddle References: <20150607081142.GF15174@isis.sigpipe.cz> To: Zsh workers Subject: Re: printf, left-justification ignored in 5.0.8 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30270.1433709564.1@thecus.kiddle.eu> Date: Sun, 07 Jun 2015 22:39:24 +0200 Message-ID: <30271.1433709564@thecus.kiddle.eu> Roman Neuhauser wrote: > > 5.0.8: > > % printf "x:%-20s:y\n" fubar > x: fubar:y That'll be my fault for not checking thoroughly enough. The - flag is fine for numeric values but for strings it seems there is separate code to allow for UTF-8 which looks in the flags array. The patch should fix this, adds a test and makes the maximum specification length test include the ' flag. Oliver diff --git a/Src/builtin.c b/Src/builtin.c index 9358e8b..8bfc419 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -4461,7 +4461,7 @@ bin_print(char *name, char **args, Options ops, int func) lleft -= chars; ptr += chars; } - if (width > 0 && flags[2]) width = -width; + if (width > 0 && flags[3]) width = -width; if (width > 0 && lchars < width) count += fprintf(fout, "%*c", width - lchars, ' '); count += fwrite(b, 1, lbytes, fout); diff --git a/Test/B03print.ztst b/Test/B03print.ztst index 48574c2..9360416 100644 --- a/Test/B03print.ztst +++ b/Test/B03print.ztst @@ -169,11 +169,15 @@ 0:%n count zeroed on format reuse >1 -# this may fill spec string with '%0+- #*.*lld\0' - 13 characters - printf '%1$0+- #-08.5dx\n' 123 +# this may fill spec string with '%0'+- #*.*lld\0' - 14 characters + printf '%1$0'"'+- #-08.5dx\n" 123 0:maximal length format specification >+00123 x + printf "x:%-20s:y\n" fubar +0:left-justification of string +>x:fubar :y + printf '%*smorning\n' -5 good 0:negative width specified >good morning