prettyness police
authorJan-Simon Pendry <pendry@ucbvax.Berkeley.EDU>
Sun, 3 Apr 1994 00:59:57 +0000 (16:59 -0800)
committerJan-Simon Pendry <pendry@ucbvax.Berkeley.EDU>
Sun, 3 Apr 1994 00:59:57 +0000 (16:59 -0800)
SCCS-vsn: bin/ps/nlist.c 8.3
SCCS-vsn: bin/ps/ps.c 8.3
SCCS-vsn: bin/ps/keyword.c 8.4
SCCS-vsn: bin/ps/print.c 8.4
SCCS-vsn: bin/ps/fmt.c 8.2
SCCS-vsn: bin/ps/extern.h 8.2
SCCS-vsn: bin/ps/ps.c 8.3

usr/src/bin/ps/extern.h
usr/src/bin/ps/fmt.c
usr/src/bin/ps/keyword.c
usr/src/bin/ps/nlist.c
usr/src/bin/ps/print.c
usr/src/bin/ps/ps.c

index 99746ba..aa2981d 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)extern.h    8.1 (Berkeley) %G%
+ *     @(#)extern.h    8.2 (Berkeley) %G%
  */
 
 struct kinfo;
  */
 
 struct kinfo;
@@ -12,6 +12,9 @@ struct nlist;
 struct var;
 struct varent;
 
 struct var;
 struct varent;
 
+extern fixpt_t ccpu;
+extern int eval, fscale, mempages, nlistread, rawcpu;
+extern int sumrusage, termwidth, totwidth;
 extern VAR var[];
 extern VARENT *vhead;
 
 extern VAR var[];
 extern VARENT *vhead;
 
index 4eb8b77..d2b2d40 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)fmt.c      8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)fmt.c      8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -27,9 +27,9 @@ static char *shquote __P((char **));
  */
 static char *
 shquote(argv)
  */
 static char *
 shquote(argv)
-       register char **argv;
+       char **argv;
 {
 {
-       register char **p, *dst, *src;
+       char **p, *dst, *src;
        static char buf[1024];          /* XXX */
 
        if (*argv == 0) {
        static char buf[1024];          /* XXX */
 
        if (*argv == 0) {
@@ -52,19 +52,19 @@ static char *
 cmdpart(arg0)
        char *arg0;
 {
 cmdpart(arg0)
        char *arg0;
 {
-       register char *cp;
+       char *cp;
 
        return ((cp = strrchr(arg0, '/')) != NULL ? cp + 1 : arg0);
 }
 
 char *
 fmt_argv(argv, cmd, maxlen)
 
        return ((cp = strrchr(arg0, '/')) != NULL ? cp + 1 : arg0);
 }
 
 char *
 fmt_argv(argv, cmd, maxlen)
-       register char **argv;
-       register char *cmd;
+       char **argv;
+       char *cmd;
        int maxlen;
 {
        int maxlen;
 {
-       register int len;
-       register char *ap, *cp;
+       int len;
+       char *ap, *cp;
 
        if (argv == 0 || argv[0] == 0) {
                if (cmd == NULL)
 
        if (argv == 0 || argv[0] == 0) {
                if (cmd == NULL)
index 6e36a95..95330e5 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)keyword.c  8.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)keyword.c  8.4 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -237,15 +237,14 @@ VAR var[] = {
 void
 showkey()
 {
 void
 showkey()
 {
-       extern int termwidth;
-       register VAR *v;
-       register int i, len;
-       register char *p, *sep;
+       VAR *v;
+       int i;
+       char *p, *sep;
 
        i = 0;
        sep = "";
        for (v = var; *(p = v->name); ++v) {
 
        i = 0;
        sep = "";
        for (v = var; *(p = v->name); ++v) {
-               len = strlen(p);
+               int len = strlen(p);
                if (termwidth && (i += len + 1) > termwidth) {
                        i = len;
                        sep = "\n";
                if (termwidth && (i += len + 1) > termwidth) {
                        i = len;
                        sep = "\n";
@@ -261,12 +260,13 @@ parsefmt(p)
        char *p;
 {
        static struct varent *vtail;
        char *p;
 {
        static struct varent *vtail;
-       register VAR *v;
-       register char *cp;
-       register struct varent *vent;
 
 #define        FMTSEP  " \t,\n"
        while (p && *p) {
 
 #define        FMTSEP  " \t,\n"
        while (p && *p) {
+               char *cp;
+               VAR *v;
+               struct varent *vent;
+
                while ((cp = strsep(&p, FMTSEP)) != NULL && *cp == '\0')
                        /* void */;
                if (!(v = findvar(cp)))
                while ((cp = strsep(&p, FMTSEP)) != NULL && *cp == '\0')
                        /* void */;
                if (!(v = findvar(cp)))
@@ -290,7 +290,6 @@ static VAR *
 findvar(p)
        char *p;
 {
 findvar(p)
        char *p;
 {
-       extern int eval;
        VAR *v, key;
        char *hp;
        int vcmp();
        VAR *v, key;
        char *hp;
        int vcmp();
@@ -310,7 +309,7 @@ findvar(p)
                        eval = 1;
                }
                parsefmt(v->alias);
                        eval = 1;
                }
                parsefmt(v->alias);
-               return((VAR *)NULL);
+               return ((VAR *)NULL);
        }
        if (!v) {
                warnx("%s: keyword not found", p);
        }
        if (!v) {
                warnx("%s: keyword not found", p);
@@ -318,12 +317,12 @@ findvar(p)
        }
        if (hp)
                v->header = hp;
        }
        if (hp)
                v->header = hp;
-       return(v);
+       return (v);
 }
 
 static int
 vcmp(a, b)
         const void *a, *b;
 {
 }
 
 static int
 vcmp(a, b)
         const void *a, *b;
 {
-        return(strcmp(((VAR *)a)->name, ((VAR *)b)->name));
+        return (strcmp(((VAR *)a)->name, ((VAR *)b)->name));
 }
 }
index ef5d348..4e66e25 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)nlist.c    8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)nlist.c    8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -57,7 +57,6 @@ extern kvm_t *kd;
 int
 donlist()
 {
 int
 donlist()
 {
-       extern int eval;
        int rval;
 #ifdef NEWVM
        int tmp;
        int rval;
 #ifdef NEWVM
        int tmp;
index d0e28b0..006c626 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)print.c    8.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c    8.4 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -40,13 +40,11 @@ static char sccsid[] = "@(#)print.c 8.3 (Berkeley) %G%";
 
 #include "ps.h"
 
 
 #include "ps.h"
 
-static void printval __P((char*, struct var *));
-
 void
 printheader()
 {
 void
 printheader()
 {
-       register VAR *v;
-       register struct varent *vent;
+       VAR *v;
+       struct varent *vent;
 
        for (vent = vhead; vent; vent = vent->next) {
                v = vent->var;
 
        for (vent = vhead; vent; vent = vent->next) {
                v = vent->var;
@@ -68,7 +66,6 @@ command(k, ve)
        KINFO *k;
        VARENT *ve;
 {
        KINFO *k;
        VARENT *ve;
 {
-       extern int termwidth, totwidth;
        VAR *v;
 
        v = ve->var;
        VAR *v;
 
        v = ve->var;
@@ -79,8 +76,8 @@ command(k, ve)
                                (void)printf("%s ", k->ki_env);
                        (void)printf("%s", k->ki_args);
                } else {
                                (void)printf("%s ", k->ki_env);
                        (void)printf("%s", k->ki_args);
                } else {
-                       register int left = termwidth - (totwidth - v->width);
-                       register char *cp;
+                       int left = termwidth - (totwidth - v->width);
+                       char *cp;
 
                        if (left < 1) /* already wrapped, just use std width */
                                left = v->width;
 
                        if (left < 1) /* already wrapped, just use std width */
                                left = v->width;
@@ -131,9 +128,9 @@ state(k, ve)
        KINFO *k;
        VARENT *ve;
 {
        KINFO *k;
        VARENT *ve;
 {
-       register struct proc *p;
-       register int flag;
-       register char *cp;
+       struct proc *p;
+       int flag;
+       char *cp;
        VAR *v;
        char buf[16];
 
        VAR *v;
        char buf[16];
 
@@ -332,12 +329,12 @@ started(k, ve)
        if (!now)
                (void)time(&now);
        if (now - k->ki_u.u_start.tv_sec < 24 * SECSPERHOUR) {
        if (!now)
                (void)time(&now);
        if (now - k->ki_u.u_start.tv_sec < 24 * SECSPERHOUR) {
-               static char fmt[] = "%l:@M%p";
-               fmt[3] = '%';                   /* I *hate* SCCS... */
+               /* I *hate* SCCS... */
+               static char fmt[] = __CONCAT("%l:%", "M%p");
                (void)strftime(buf, sizeof(buf) - 1, fmt, tp);
        } else if (now - k->ki_u.u_start.tv_sec < 7 * SECSPERDAY) {
                (void)strftime(buf, sizeof(buf) - 1, fmt, tp);
        } else if (now - k->ki_u.u_start.tv_sec < 7 * SECSPERDAY) {
-               static char fmt[] = "%a@I%p";
-               fmt[2] = '%';                   /* I *hate* SCCS... */
+               /* I *hate* SCCS... */
+               static char fmt[] = __CONCAT("%a%", "I%p");
                (void)strftime(buf, sizeof(buf) - 1, fmt, tp);
        } else
                (void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp);
                (void)strftime(buf, sizeof(buf) - 1, fmt, tp);
        } else
                (void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp);
@@ -439,7 +436,6 @@ cputime(k, ve)
        KINFO *k;
        VARENT *ve;
 {
        KINFO *k;
        VARENT *ve;
 {
-       extern int sumrusage;
        VAR *v;
        long secs;
        long psecs;     /* "parts" of a second. first micro, then centi */
        VAR *v;
        long secs;
        long psecs;     /* "parts" of a second. first micro, then centi */
@@ -479,8 +475,6 @@ double
 getpcpu(k)
        KINFO *k;
 {
 getpcpu(k)
        KINFO *k;
 {
-       extern fixpt_t ccpu;
-       extern int fscale, nlistread, rawcpu;
        struct proc *p;
        static int failure;
 
        struct proc *p;
        static int failure;
 
@@ -516,7 +510,6 @@ double
 getpmem(k)
        KINFO *k;
 {
 getpmem(k)
        KINFO *k;
 {
-       extern int mempages, nlistread;
        static int failure;
        struct proc *p;
        struct eproc *e;
        static int failure;
        struct proc *p;
        struct eproc *e;
@@ -617,6 +610,48 @@ trss(k, ve)
  * Generic output routines.  Print fields from various prototype
  * structures.
  */
  * Generic output routines.  Print fields from various prototype
  * structures.
  */
+static void
+printval(bp, v)
+       char *bp;
+       VAR *v;
+{
+       static char ofmt[32] = "%";
+       char *fcp, *cp;
+
+       cp = ofmt + 1;
+       fcp = v->fmt;
+       if (v->flag & LJUST)
+               *cp++ = '-';
+       *cp++ = '*';
+       while (*cp++ = *fcp++);
+
+       switch (v->type) {
+       case CHAR:
+               (void)printf(ofmt, v->width, *(char *)bp);
+               break;
+       case UCHAR:
+               (void)printf(ofmt, v->width, *(u_char *)bp);
+               break;
+       case SHORT:
+               (void)printf(ofmt, v->width, *(short *)bp);
+               break;
+       case USHORT:
+               (void)printf(ofmt, v->width, *(u_short *)bp);
+               break;
+       case LONG:
+               (void)printf(ofmt, v->width, *(long *)bp);
+               break;
+       case ULONG:
+               (void)printf(ofmt, v->width, *(u_long *)bp);
+               break;
+       case KPTR:
+               (void)printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);
+               break;
+       default:
+               errx(1, "unknown type %d", v->type);
+       }
+}
+
 void
 pvar(k, ve)
        KINFO *k;
 void
 pvar(k, ve)
        KINFO *k;
@@ -666,45 +701,3 @@ rvar(k, ve)
        else
                (void)printf("%*s", v->width, "-");
 }
        else
                (void)printf("%*s", v->width, "-");
 }
-
-static void
-printval(bp, v)
-       char *bp;
-       VAR *v;
-{
-       static char ofmt[32] = "%";
-       register char *fcp, *cp;
-
-       cp = ofmt + 1;
-       fcp = v->fmt;
-       if (v->flag & LJUST)
-               *cp++ = '-';
-       *cp++ = '*';
-       while (*cp++ = *fcp++);
-
-       switch (v->type) {
-       case CHAR:
-               (void)printf(ofmt, v->width, *(char *)bp);
-               break;
-       case UCHAR:
-               (void)printf(ofmt, v->width, *(u_char *)bp);
-               break;
-       case SHORT:
-               (void)printf(ofmt, v->width, *(short *)bp);
-               break;
-       case USHORT:
-               (void)printf(ofmt, v->width, *(u_short *)bp);
-               break;
-       case LONG:
-               (void)printf(ofmt, v->width, *(long *)bp);
-               break;
-       case ULONG:
-               (void)printf(ofmt, v->width, *(u_long *)bp);
-               break;
-       case KPTR:
-               (void)printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);
-               break;
-       default:
-               errx(1, "unknown type %d", v->type);
-       }
-}
index 700a84e..d12d261 100644 (file)
@@ -12,7 +12,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)ps.c       8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)ps.c       8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -78,13 +78,14 @@ main(argc, argv)
        int argc;
        char *argv[];
 {
        int argc;
        char *argv[];
 {
-       register struct kinfo_proc *kp;
-       register struct varent *vent;
-       int nentries;
-       register int i;
+       struct kinfo_proc *kp;
+       struct varent *vent;
        struct winsize ws;
        dev_t ttydev;
        struct winsize ws;
        dev_t ttydev;
-       int all, ch, flag, fmt, lineno, pid, prtheader, uid, wflag, what, xflg;
+       pid_t pid;
+       uid_t uid;
+       int all, ch, flag, i, fmt, lineno, nentries;
+       int prtheader, wflag, what, xflg;
        char *nlistf, *memf, *swapf, errbuf[256];
 
        if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
        char *nlistf, *memf, *swapf, errbuf[256];
 
        if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
@@ -99,7 +100,8 @@ main(argc, argv)
                argv[1] = kludge_oldps_options(argv[1]);
 
        all = fmt = prtheader = wflag = xflg = 0;
                argv[1] = kludge_oldps_options(argv[1]);
 
        all = fmt = prtheader = wflag = xflg = 0;
-       pid = uid = -1;
+       pid = -1;
+       uid = (uid_t) -1;
        ttydev = NODEV;
        memf = nlistf = swapf = NULL;
        while ((ch = getopt(argc, argv,
        ttydev = NODEV;
        memf = nlistf = swapf = NULL;
        while ((ch = getopt(argc, argv,
@@ -153,7 +155,7 @@ main(argc, argv)
                        fmt = 1;
                        break;
                case 'p':
                        fmt = 1;
                        break;
                case 'p':
-                       pid = atoi(optarg);
+                       pid = atol(optarg);
                        xflg = 1;
                        break;
                case 'r':
                        xflg = 1;
                        break;
                case 'r':
@@ -252,7 +254,7 @@ main(argc, argv)
        /*
         * get proc list
         */
        /*
         * get proc list
         */
-       if (uid != -1) {
+       if (uid != (uid_t) -1) {
                what = KERN_PROC_UID;
                flag = uid;
        } else if (ttydev != NODEV) {
                what = KERN_PROC_UID;
                flag = uid;
        } else if (ttydev != NODEV) {
@@ -308,9 +310,9 @@ main(argc, argv)
 static void
 scanvars()
 {
 static void
 scanvars()
 {
-       register struct varent *vent;
-       register VAR *v;
-       register int i;
+       struct varent *vent;
+       VAR *v;
+       int i;
 
        for (vent = vhead; vent; vent = vent->next) {
                v = vent->var;
 
        for (vent = vhead; vent; vent = vent->next) {
                v = vent->var;
@@ -333,7 +335,7 @@ fmt(fn, ki, comm, maxlen)
        char *comm;
        int maxlen;
 {
        char *comm;
        int maxlen;
 {
-       register char *s;
+       char *s;
 
        if ((s =
            fmt_argv((*fn)(kd, ki->ki_p, termwidth), comm, maxlen)) == NULL)
 
        if ((s =
            fmt_argv((*fn)(kd, ki->ki_p, termwidth), comm, maxlen)) == NULL)
@@ -345,12 +347,12 @@ static void
 saveuser(ki)
        KINFO *ki;
 {
 saveuser(ki)
        KINFO *ki;
 {
-       register struct usave *usp = &ki->ki_u;
        struct pstats pstats;
        struct pstats pstats;
-       extern char *fmt_argv();
+       struct usave *usp;
 
 
+       usp = &ki->ki_u;
        if (kvm_read(kd, (u_long)&KI_PROC(ki)->p_addr->u_stats,
        if (kvm_read(kd, (u_long)&KI_PROC(ki)->p_addr->u_stats,
-                    (char *)&pstats, sizeof(pstats)) == sizeof(pstats)) {
+           (char *)&pstats, sizeof(pstats)) == sizeof(pstats)) {
                /*
                 * The u-area might be swapped out, and we can't get
                 * at it because we have a crashdump and no swap.
                /*
                 * The u-area might be swapped out, and we can't get
                 * at it because we have a crashdump and no swap.
@@ -462,7 +464,11 @@ kludge_oldps_options(s)
 static void
 usage()
 {
 static void
 usage()
 {
+
        (void)fprintf(stderr,
        (void)fprintf(stderr,
-"usage: ps [-aChjlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty]\n\t  [-M core] [-N system] [-W swap]\n       ps [-L]\n");
+           "usage:\t%s\n\t   %s\n\t%s\n",
+           "ps [-aChjlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty]",
+           "[-M core] [-N system] [-W swap]",
+           "ps [-L]");
        exit(1);
 }
        exit(1);
 }