as suggested in PR 1347, by Kenneth Stailey, make "RE" and "SL" fields

show up as two digits, max, displaying "99" if > 99.  allow any field with
an unsigned value to be specified as printing that way (though right now
it's only used for RE and SL, which are both unsigned longs).  This fix
is substantially different than that suggested in the PR.
This commit is contained in:
cgd 1995-08-14 05:00:03 +00:00
parent e7b36fb1b4
commit 731f8de0fa
3 changed files with 26 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: keyword.c,v 1.9 1995/05/08 23:11:31 cgd Exp $ */
/* $NetBSD: keyword.c,v 1.10 1995/08/14 05:00:03 cgd Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94";
#else
static char rcsid[] = "$NetBSD: keyword.c,v 1.9 1995/05/08 23:11:31 cgd Exp $";
static char rcsid[] = "$NetBSD: keyword.c,v 1.10 1995/08/14 05:00:03 cgd Exp $";
#endif
#endif /* not lint */
@ -136,7 +136,7 @@ VAR var[] = {
{"pmem", "", "%mem"},
{"ppid", "PPID", NULL, 0, evar, PIDLEN, EOFF(e_ppid), LONG, PIDFMT},
{"pri", "PRI", NULL, 0, pri, 3},
{"re", "RE", NULL, 0, pvar, 3, POFF(p_swtime), ULONG, "d"},
{"re", "RE", NULL, TWODGT, pvar, 3, POFF(p_swtime), ULONG, "d"},
{"rgid", "RGID", NULL, 0, evar, UIDLEN, EOFF(e_pcred.p_rgid),
ULONG, UIDFMT},
{"rlink", "RLINK", NULL, 0, pvar, 8, POFF(p_back), KPTR, "x"},
@ -152,7 +152,7 @@ VAR var[] = {
{"sigignore", "IGNORED",
NULL, 0, pvar, 8, POFF(p_sigignore), LONG, "x"},
{"sigmask", "BLOCKED", NULL, 0, pvar, 8, POFF(p_sigmask), LONG, "x"},
{"sl", "SL", NULL, 0, pvar, 3, POFF(p_slptime), ULONG, "d"},
{"sl", "SL", NULL, TWODGT, pvar, 3, POFF(p_slptime), ULONG, "d"},
{"start", "STARTED", NULL, LJUST|USER, started, 8},
{"stat", "", "state"},
{"state", "STAT", NULL, 0, state, 4},

View File

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.24 1995/06/07 16:29:30 cgd Exp $ */
/* $NetBSD: print.c,v 1.25 1995/08/14 05:00:05 cgd Exp $ */
/*-
* Copyright (c) 1990, 1993, 1994
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else
static char rcsid[] = "$NetBSD: print.c,v 1.24 1995/06/07 16:29:30 cgd Exp $";
static char rcsid[] = "$NetBSD: print.c,v 1.25 1995/08/14 05:00:05 cgd Exp $";
#endif
#endif /* not lint */
@ -695,37 +695,46 @@ printval(bp, v)
*cp++ = '*';
while (*cp++ = *fcp++);
/*
* Note that the "TWODGT" check is nonsensical for types
* that are or can be signed.
*/
#define GET(type) (*(type *)bp)
#define CHK_TWODGT(n) (((n) > 99) && (v->flag & TWODGT) ? 99 : (n))
switch (v->type) {
case CHAR:
(void)printf(ofmt, v->width, *(char *)bp);
(void)printf(ofmt, v->width, GET(char));
break;
case UCHAR:
(void)printf(ofmt, v->width, *(u_char *)bp);
(void)printf(ofmt, v->width, CHK_TWODGT(GET(u_char)));
break;
case SHORT:
(void)printf(ofmt, v->width, *(short *)bp);
(void)printf(ofmt, v->width, GET(short));
break;
case USHORT:
(void)printf(ofmt, v->width, *(u_short *)bp);
(void)printf(ofmt, v->width, CHK_TWODGT(GET(u_short)));
break;
case INT:
(void)printf(ofmt, v->width, *(int *)bp);
(void)printf(ofmt, v->width, GET(int));
break;
case UINT:
(void)printf(ofmt, v->width, *(u_int *)bp);
(void)printf(ofmt, v->width, CHK_TWODGT(GET(u_int)));
break;
case LONG:
(void)printf(ofmt, v->width, *(long *)bp);
(void)printf(ofmt, v->width, GET(long));
break;
case ULONG:
(void)printf(ofmt, v->width, *(u_long *)bp);
(void)printf(ofmt, v->width, CHK_TWODGT(GET(u_long)));
break;
case KPTR:
(void)printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);
(void)printf(ofmt, v->width, GET(u_long) &~ KERNBASE);
break;
default:
errx(1, "unknown type %d", v->type);
}
#undef GET
#undef CHK_TWODGT
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: ps.h,v 1.8 1995/05/18 20:33:26 mycroft Exp $ */
/* $NetBSD: ps.h,v 1.9 1995/08/14 05:00:07 cgd Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -67,6 +67,7 @@ typedef struct var {
#define COMM 0x01 /* needs exec arguments and environment (XXX) */
#define LJUST 0x02 /* left adjust on output (trailing blanks) */
#define USER 0x04 /* needs user structure */
#define TWODGT 0x08 /* print as two digits, as 99 if > 99 */
u_int flag;
/* output routine */
void (*oproc) __P((struct kinfo *, struct varent *));