From: Daniel Shahaf <danielsh@apache.org>
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 [thread overview]
Message-ID: <20191224182509.23800-2-danielsh@apache.org> (raw)
In-Reply-To: <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'
prev parent reply other threads:[~2019-12-24 18:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-24 18:25 [PATCH 1/2] Add zformat unit tests Daniel Shahaf
2019-12-24 18:25 ` Daniel Shahaf [this message]
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=20191224182509.23800-2-danielsh@apache.org \
--to=danielsh@apache.org \
--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).