summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authormartin <martin@NetBSD.org>2020-04-25 10:50:47 +0000
committermartin <martin@NetBSD.org>2020-04-25 10:50:47 +0000
commitc4126712cffab7cbfc72800e43c40badd26df354 (patch)
tree6190fcc0d6f1f3d33c39d87f5a213ffe101433da /bin
parent4fc511dd0d48aff2c1a4ae1bf4eaa3c45fd201f7 (diff)
Pull up following revision(s) (requested by simonb in ticket #853):
bin/csh/time.c: revision 1.22 usr.bin/time/time.c: revision 1.24 bin/csh/extern.h: revision 1.32 usr.bin/time/time.1: revision 1.29 usr.bin/time/ext.h: revision 1.4 Add '-t' option for tcsh-style time output.
Diffstat (limited to 'bin')
-rw-r--r--bin/csh/extern.h4
-rw-r--r--bin/csh/time.c21
2 files changed, 13 insertions, 12 deletions
diff --git a/bin/csh/extern.h b/bin/csh/extern.h
index 7fea548ceb2..ef75250332d 100644
--- a/bin/csh/extern.h
+++ b/bin/csh/extern.h
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.31 2019/01/05 16:54:00 christos Exp $ */
+/* $NetBSD: extern.h,v 1.31.2.1 2020/04/25 10:50:47 martin Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -297,7 +297,7 @@ void plist(struct varent *);
*/
void donice(Char **, struct command *);
void dotime(Char **, struct command *);
-void prusage1(FILE *, const char *, struct rusage *, struct rusage *,
+void prusage1(FILE *, const char *, int, struct rusage *, struct rusage *,
struct timespec *, struct timespec *);
void prusage(FILE *, struct rusage *, struct rusage *, struct timespec *,
struct timespec *);
diff --git a/bin/csh/time.c b/bin/csh/time.c
index 9303ae296db..60f3953cf8f 100644
--- a/bin/csh/time.c
+++ b/bin/csh/time.c
@@ -1,4 +1,4 @@
-/* $NetBSD: time.c,v 1.21 2017/07/15 14:35:55 christos Exp $ */
+/* $NetBSD: time.c,v 1.21.8.1 2020/04/25 10:50:47 martin Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: time.c,v 1.21 2017/07/15 14:35:55 christos Exp $");
+__RCSID("$NetBSD: time.c,v 1.21.8.1 2020/04/25 10:50:47 martin Exp $");
#endif
#endif /* not lint */
@@ -49,7 +49,7 @@ __RCSID("$NetBSD: time.c,v 1.21 2017/07/15 14:35:55 christos Exp $");
/*
* C Shell - routines handling process timing and niceing
*/
-static void pdeltat(FILE *, struct timeval *, struct timeval *);
+static void pdeltat(FILE *, int, struct timeval *, struct timeval *);
static void pcsecs(FILE *, long);
#ifndef NOT_CSH
@@ -138,12 +138,13 @@ prusage(FILE *fp, struct rusage *r0, struct rusage *r1, struct timespec *e,
cp = short2str(vp->vec[1]);
else
cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
- prusage1(fp, cp, r0, r1, e, b);
+ prusage1(fp, cp, 1, r0, r1, e, b);
}
#endif
void
-prusage1(FILE *fp, const char *cp, struct rusage *r0, struct rusage *r1,
+prusage1(FILE *fp, const char *cp, int prec,
+ struct rusage *r0, struct rusage *r1,
struct timespec *e, struct timespec *b)
{
long i;
@@ -201,10 +202,10 @@ prusage1(FILE *fp, const char *cp, struct rusage *r0, struct rusage *r1,
(void)fprintf(fp, "%ld", r1->ru_minflt - r0->ru_minflt);
break;
case 'S': /* system CPU time used */
- pdeltat(fp, &r1->ru_stime, &r0->ru_stime);
+ pdeltat(fp, prec, &r1->ru_stime, &r0->ru_stime);
break;
case 'U': /* user CPU time used */
- pdeltat(fp, &r1->ru_utime, &r0->ru_utime);
+ pdeltat(fp, prec, &r1->ru_utime, &r0->ru_utime);
break;
case 'W': /* number of swaps */
i = r1->ru_nswap - r0->ru_nswap;
@@ -234,13 +235,13 @@ prusage1(FILE *fp, const char *cp, struct rusage *r0, struct rusage *r1,
}
static void
-pdeltat(FILE *fp, struct timeval *t1, struct timeval *t0)
+pdeltat(FILE *fp, int prec, struct timeval *t1, struct timeval *t0)
{
struct timeval td;
timersub(t1, t0, &td);
- (void)fprintf(fp, "%ld.%01ld", (long)td.tv_sec,
- (long)(td.tv_usec / 100000));
+ (void)fprintf(fp, "%ld.%0*ld", (long)td.tv_sec,
+ prec, (long)(td.tv_usec / 100000));
}
#define P2DIG(fp, i) (void)fprintf(fp, "%ld%ld", (i) / 10, (i) % 10)