p_tv() is identical to p_ts() in every way except for the subsecond conversion constants.
Better to write p_ts() once: in p_tv(), convert from timeval to timespec and call p_ts(). ok? Index: c_sh.c =================================================================== RCS file: /cvs/src/bin/ksh/c_sh.c,v retrieving revision 1.64 diff -u -p -r1.64 c_sh.c --- c_sh.c 22 May 2020 07:50:07 -0000 1.64 +++ c_sh.c 12 Sep 2023 03:07:16 -0000 @@ -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