mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-19 11:31:26 +01:00
45137: zformat: Allow the specifying minimum width and a dot with an empty maximum width.
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.
This commit is contained in:
parent
8e0253af02
commit
525faae549
3 changed files with 7 additions and 2 deletions
|
@ -1,5 +1,9 @@
|
|||
2019-12-26 Daniel Shahaf <danielsh@apache.org>
|
||||
|
||||
* 45137: Src/Modules/zutil.c, Test/V13zformat.ztst: zformat:
|
||||
Allow the specifying minimum width and a dot with an empty
|
||||
maximum width.
|
||||
|
||||
* 45138: Src/Modules/zutil.c, Test/V13zformat.ztst: Add zformat
|
||||
unit tests.
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
Loading…
Reference in a new issue