diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2019-01-05 13:25:18 +0100 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2019-01-05 13:25:18 +0100 |
commit | 7e6a3d73413ad665a87cecf39d1dd05a91c1a31e (patch) | |
tree | 6e826685afbd476b340d311d2c08af12b3e81a8e /Src/utils.c | |
parent | feaf8570c138e4372ae9517f1f5658ae74640c41 (diff) | |
parent | 325fceab3b4ffa871777bacc420e0e8efcb0afb9 (diff) | |
download | zsh-7e6a3d73413ad665a87cecf39d1dd05a91c1a31e.tar.gz zsh-7e6a3d73413ad665a87cecf39d1dd05a91c1a31e.zip |
New upstream release candidate 5.6.2-test-3
Merge branch 'upstream' at 'zsh-5.6.2-test-3' into branch debian
Diffstat (limited to 'Src/utils.c')
-rw-r--r-- | Src/utils.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Src/utils.c b/Src/utils.c index e43a3cdb4..32f600858 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -3334,19 +3334,28 @@ morefmt: #endif switch (*fmt++) { case '.': - if (ztrftimebuf(&bufsize, digs)) - return -1; + { + long fnsec = nsec; if (digs > 9) digs = 9; + if (ztrftimebuf(&bufsize, digs)) + return -1; if (digs < 9) { int trunc; - for (trunc = 8 - digs; trunc; trunc--) - nsec /= 10; - nsec = (nsec + 8) / 10; + long max = 100000000; + for (trunc = 8 - digs; trunc; trunc--) { + max /= 10; + fnsec /= 10; + } + max -= 1; + fnsec = (fnsec + 5) / 10; + if (fnsec > max) + fnsec = max; } - sprintf(buf, "%0*ld", digs, nsec); + sprintf(buf, "%0*ld", digs, fnsec); buf += digs; break; + } case '\0': /* Guard against premature end of string */ *buf++ = '%'; @@ -3837,7 +3846,7 @@ sepjoin(char **s, char *sep, int heap) char sepbuf[2]; if (!*s) - return heap ? "" : ztrdup(""); + return heap ? dupstring("") : ztrdup(""); if (!sep) { /* optimise common case that ifs[0] is space */ if (ifs && *ifs != ' ') { |