diff options
author | Miles Bader <miles@gnu.org> | 1996-10-08 21:20:31 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-10-08 21:20:31 +0000 |
commit | b6608f1e8151ec432ba3d573f329f6fb51349b61 (patch) | |
tree | f24627a962d97b1a9316e0e1379fc4a11571e302 /libps | |
parent | ffe687db775393a05cdeae8550f9b6595d424678 (diff) |
(ps_emit_seconds, ps_emit_minutes):
Interpret PS_FMT_FIELD_COLON_MOD flag to mean `print zero as "-"'.
Diffstat (limited to 'libps')
-rw-r--r-- | libps/spec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/libps/spec.c b/libps/spec.c index 04aff7f7..adebf40c 100644 --- a/libps/spec.c +++ b/libps/spec.c @@ -462,8 +462,11 @@ ps_emit_seconds (struct proc_stat *ps, struct ps_fmt_field *field, FG (field, void)(ps, &tv); - fmt_seconds (&tv, !(field->flags & PS_FMT_FIELD_AT_MOD), prec, ABS (width), - buf, sizeof (buf)); + if ((field->flags & PS_FMT_FIELD_COLON_MOD) && tv.tv_sec == 0) + strcpy (buf, "-"); + else + fmt_seconds (&tv, !(field->flags & PS_FMT_FIELD_AT_MOD), prec, ABS (width), + buf, sizeof (buf)); return ps_stream_write_field (stream, buf, width); } @@ -478,8 +481,11 @@ ps_emit_minutes (struct proc_stat *ps, struct ps_fmt_field *field, FG (field, int)(ps, &tv); - fmt_minutes (&tv, !(field->flags & PS_FMT_FIELD_AT_MOD), ABS (width), - buf, sizeof (buf)); + if ((field->flags & PS_FMT_FIELD_COLON_MOD) && tv.tv_sec < 60) + strcpy (buf, "-"); + else + fmt_minutes (&tv, !(field->flags & PS_FMT_FIELD_AT_MOD), ABS (width), + buf, sizeof (buf)); return ps_stream_write_field (stream, buf, width); } |