diff options
author | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2023-09-14 18:32:04 +0000 |
---|---|---|
committer | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2023-09-14 18:32:04 +0000 |
commit | 05d6d03a7d1d98b3c545a840954ab5e68b0e9ac7 (patch) | |
tree | 8477e7eaf62d38d7970a1cba8d326d21baaaa2c5 /bin/ksh | |
parent | a0fe03c666bdc45a18949d2b14beddd43e1b267b (diff) |
sh(1), ksh(1): reimplement p_tv() with p_ts()
p_tv() is identical to p_ts(). Better to not have two copies: in
p_tv(), convert the timeval to a timespec and pass it to p_ts().
With input from tb@ and millert@.
Thread: https://marc.info/?l=openbsd-tech&m=169448818503541&w=2
ok tb@ millert@
Diffstat (limited to 'bin/ksh')
-rw-r--r-- | bin/ksh/c_sh.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c index 98f5e5e4f6d..32e692674ce 100644 --- a/bin/ksh/c_sh.c +++ b/bin/ksh/c_sh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_sh.c,v 1.64 2020/05/22 07:50:07 benno Exp $ */ +/* $OpenBSD: c_sh.c,v 1.65 2023/09/14 18:32:03 cheloha Exp $ */ /* * built-in Bourne commands @@ -680,14 +680,10 @@ static void p_tv(struct shf *shf, int posix, struct timeval *tv, int width, char *prefix, char *suffix) { - if (posix) - shf_fprintf(shf, "%s%*lld.%02ld%s", prefix ? prefix : "", - width, (long long)tv->tv_sec, tv->tv_usec / 10000, suffix); - else - shf_fprintf(shf, "%s%*lldm%02lld.%02lds%s", prefix ? prefix : "", - width, (long long)tv->tv_sec / 60, - (long long)tv->tv_sec % 60, - tv->tv_usec / 10000, suffix); + struct timespec ts; + + TIMEVAL_TO_TIMESPEC(tv, &ts); + p_ts(shf, posix, &ts, width, prefix, suffix); } static void |