diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-03-29 12:30:33 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-03-29 12:30:33 +0100 |
commit | 8f2cb7ab26b9c720c24cdeffb624bfe0c2352353 (patch) | |
tree | 8d76825f24632d338118919b0553f542fdd3a8aa /procps | |
parent | 6c852bfcadd78f53ec7a5f35882636a2a4a66eb0 (diff) | |
download | busybox-8f2cb7ab26b9c720c24cdeffb624bfe0c2352353.tar.gz |
libbb: introduce and use strftime_[YYYYMMDD]HHMMSS()
function old new delta
strftime_fmt - 53 +53
strftime_YYYYMMDDHHMMSS - 12 +12
strftime_HHMMSS - 12 +12
human_time 44 43 -1
fmtstr_t 9 - -9
step_time 361 345 -16
watch_main 261 232 -29
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 0/3 up/down: 77/-55) Total: 22 bytes
text data bss dec hex filename
919203 932 17692 937827 e4f63 busybox_old
919209 932 17692 937833 e4f69 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r-- | procps/watch.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/procps/watch.c b/procps/watch.c index 36af1cca7..0397f21bf 100644 --- a/procps/watch.c +++ b/procps/watch.c @@ -69,7 +69,6 @@ int watch_main(int argc UNUSED_PARAM, char **argv) printf("\033[H""\033[J"); if (!(opt & 0x2)) { // no -t const unsigned time_len = sizeof("1234-67-90 23:56:89"); - time_t t; // STDERR_FILENO is procps3 compat: // "watch ls 2>/dev/null" does not detect tty size @@ -79,10 +78,13 @@ int watch_main(int argc UNUSED_PARAM, char **argv) free(header); header = xasprintf("Every %us: %-*s", period, (int)width, cmd); } - time(&t); - if (time_len < width) - strftime(header + width - time_len, time_len, - "%Y-%m-%d %H:%M:%S", localtime(&t)); + if (time_len < width) { + strftime_YYYYMMDDHHMMSS( + header + width - time_len, + time_len, + /*time_t*:*/ NULL + ); + } // compat: empty line between header and cmd output printf("%s\n\n", header); |