From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5c097702 for ; Tue, 24 Dec 2019 18:26:04 +0000 (UTC) Received: (qmail 2167 invoked by alias); 24 Dec 2019 18:25:55 -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: List-Unsubscribe: X-Seq: 45137 Received: (qmail 8260 invoked by uid 1010); 24 Dec 2019 18:25:55 -0000 X-Qmail-Scanner-Diagnostics: from wout2-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25670. spamassassin: 3.4.2. Clear:RC:0(64.147.123.25):SA:0(-1.9/5.0):. Processed in 4.73958 secs); 24 Dec 2019 18:25:55 -0000 X-Envelope-From: danielsh@apache.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: softfail (ns1.primenet.com.au: transitioning SPF record at amazonses.com does not designate 64.147.123.25 as permitted sender) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvddvvddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhestddtredtre dttdenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurghnihgvlhhshhesrghp rggthhgvrdhorhhgqeenucfkphepjeelrddukedtrdehjedrudduleenucfrrghrrghmpe hmrghilhhfrhhomhepuggrnhhivghlshhhsegrphgrtghhvgdrohhrghenucevlhhushht vghrufhiiigvpedt X-ME-Proxy: From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 2/2] zformat: Allow the specifying minimum width and a dot with an empty maximum width. Date: Tue, 24 Dec 2019 18:25:09 +0000 Message-Id: <20191224182509.23800-2-danielsh@apache.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191224182509.23800-1-danielsh@apache.org> References: <20191224182509.23800-1-danielsh@apache.org> Before this commit, format specs such as '%5.s' would be printed literally. Now, they are treated as equivalent to '%5s'. The '.' character is not allowed to be used in specs, so there is no incompatibility. --- I'm thinking of pushing 45131 and this to a new "5.9" branch in git, and merge that branch to master after 5.8 when we're happy there won't be a 5.8.1. This way, 5.8 won't be destabilized but the patches will live in git, rather than in the list archives. Cheers, Daniel Src/Modules/zutil.c | 3 +-- Test/V13zformat.ztst | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index de5fe8034..7d9bf05d6 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -797,8 +797,7 @@ static char *zformat_substring(char* instr, char **specs, char **outp, if ((*s == '.' || testit) && idigit(s[1])) { for (max = 0, s++; idigit(*s); s++) max = (max * 10) + (int) STOUC(*s) - '0'; - } - else if (testit) + } else if (*s == '.' || testit) s++; if (testit && STOUC(*s)) { diff --git a/Test/V13zformat.ztst b/Test/V13zformat.ztst index d8de2bb04..982866e13 100644 --- a/Test/V13zformat.ztst +++ b/Test/V13zformat.ztst @@ -17,12 +17,14 @@ zformat_and_print_s '%s' foo zformat_and_print_s '%5s' min zformat_and_print_s '%-5s' neg + zformat_and_print_s '%5.s' empty zformat_and_print_s '%.5s' max zformat_and_print_s '%.5s' truncated 0:basic zformat test >'foo' >'min ' >' neg' +>'empty' >'max' >'trunc'