diff options
-rw-r--r-- | contrib/top/top.c | 2 | ||||
-rw-r--r-- | usr.bin/top/machine.c | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/contrib/top/top.c b/contrib/top/top.c index eac2ecc..b38300f 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -450,7 +450,7 @@ char *argv[]; } /* initialize the kernel memory interface */ - if (machine_init(&statics) == -1) + if (machine_init(&statics, do_unames) == -1) { exit(1); } diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index cc12705..d6fa14c 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -60,7 +60,11 @@ extern struct process_select ps; extern char* printable(char *); static int smpmode; enum displaymodes displaymode; +#ifdef TOP_USERNAME_LEN +static int namelength = TOP_USERNAME_LEN; +#else static int namelength = 8; +#endif static int cmdlengthdelta; /* Prototypes for top internals */ @@ -223,7 +227,7 @@ static void getsysctl(const char *name, void *ptr, size_t len); static int swapmode(int *retavail, int *retfree); int -machine_init(struct statics *statics) +machine_init(struct statics *statics, char do_unames) { int pagesize; size_t modelen; @@ -237,9 +241,11 @@ machine_init(struct statics *statics) modelen != sizeof(smpmode)) smpmode = 0; - while ((pw = getpwent()) != NULL) { + if (do_unames) { + while ((pw = getpwent()) != NULL) { if (strlen(pw->pw_name) > namelength) namelength = strlen(pw->pw_name); + } } if (smpmode && namelength > SMPUNAMELEN) namelength = SMPUNAMELEN; |