Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/csh Add a variant that passes the format, so that time(1...



details:   https://anonhg.NetBSD.org/src/rev/f5697f973f33
branches:  trunk
changeset: 825460:f5697f973f33
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jul 15 14:35:55 2017 +0000

description:
Add a variant that passes the format, so that time(1) can use it.

diffstat:

 bin/csh/extern.h |   4 +++-
 bin/csh/time.c   |  29 +++++++++++++++++------------
 2 files changed, 20 insertions(+), 13 deletions(-)

diffs (84 lines):

diff -r 3c3fcf88a9c2 -r f5697f973f33 bin/csh/extern.h
--- a/bin/csh/extern.h  Sat Jul 15 14:34:08 2017 +0000
+++ b/bin/csh/extern.h  Sat Jul 15 14:35:55 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.29 2013/07/16 17:47:43 christos Exp $ */
+/* $NetBSD: extern.h,v 1.30 2017/07/15 14:35:55 christos Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -297,6 +297,8 @@
  */
 void donice(Char **, struct command *);
 void dotime(Char **, struct command *);
+void prusage1(FILE *, const char *, struct rusage *, struct rusage *,
+            struct timespec *, struct timespec *);
 void prusage(FILE *, struct rusage *, struct rusage *, struct timespec *,
              struct timespec *);
 void ruadd(struct rusage *, struct rusage *);
diff -r 3c3fcf88a9c2 -r f5697f973f33 bin/csh/time.c
--- a/bin/csh/time.c    Sat Jul 15 14:34:08 2017 +0000
+++ b/bin/csh/time.c    Sat Jul 15 14:35:55 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: time.c,v 1.20 2013/07/16 17:47:43 christos Exp $ */
+/* $NetBSD: time.c,v 1.21 2017/07/15 14:35:55 christos 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.20 2013/07/16 17:47:43 christos Exp $");
+__RCSID("$NetBSD: time.c,v 1.21 2017/07/15 14:35:55 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -124,32 +124,37 @@
     ru->ru_nvcsw += ru2->ru_nvcsw;
     ru->ru_nivcsw += ru2->ru_nivcsw;
 }
-#endif /* NOT_CSH */
 
 void
 prusage(FILE *fp, struct rusage *r0, struct rusage *r1, struct timespec *e,
         struct timespec *b)
 {
-#ifndef NOT_CSH
     struct varent *vp;
+    const char *cp;
+
+    vp = adrof(STRtime);
+
+    if (vp && vp->vec[0] && vp->vec[1])
+       cp = short2str(vp->vec[1]);
+    else
+       cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
+    prusage1(fp, cp, r0, r1, e, b);
+}
 #endif
-    const char *cp;
+
+void
+prusage1(FILE *fp, const char *cp, struct rusage *r0, struct rusage *r1,
+    struct timespec *e, struct timespec *b)
+{
     long i;
     time_t t;
     time_t ms;
 
-    cp = "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
     ms = (e->tv_sec - b->tv_sec) * 100 + (e->tv_nsec - b->tv_nsec) / 10000000;
     t = (r1->ru_utime.tv_sec - r0->ru_utime.tv_sec) * 100 +
         (r1->ru_utime.tv_usec - r0->ru_utime.tv_usec) / 10000 +
         (r1->ru_stime.tv_sec - r0->ru_stime.tv_sec) * 100 +
         (r1->ru_stime.tv_usec - r0->ru_stime.tv_usec) / 10000;
-#ifndef NOT_CSH
-    vp = adrof(STRtime);
-
-    if (vp && vp->vec[0] && vp->vec[1])
-       cp = short2str(vp->vec[1]);
-#endif
 
     for (; *cp; cp++)
        if (*cp != '%')



Home | Main Index | Thread Index | Old Index