top(1): style and related

- style(9)
- remove now-defunct comments
- remove getuid check for low delay
- expand range of format_k
This commit is contained in:
eadler 2018-06-12 07:14:12 +00:00
parent 5246c095ce
commit b7985cdc96
6 changed files with 8 additions and 13 deletions

View File

@ -195,7 +195,8 @@ static char err_listem[] =
#define STRMAX 80
char *err_string(void)
char *
err_string(void)
{
struct errs *errp;
int cnt = 0;

View File

@ -53,10 +53,6 @@ struct system_info
int ncpus;
};
/* cpu_states is an array of percentages * 10. For example,
the (integer) value 105 is 10.5% (or .105).
*/
/*
* the process_select struct tells get_process_info what processes
* and information we are interested in seeing

View File

@ -925,7 +925,7 @@ main(int argc, char *argv[])
new_message(MT_standout, "Seconds to delay: ");
if ((i = readline(tempbuf1, 8, true)) > -1)
{
if ((delay = i) == 0 && getuid() != 0)
if ((delay = i) == 0)
{
delay = 1;
}
@ -1034,8 +1034,7 @@ main(int argc, char *argv[])
putchar('\r');
break;
case CMD_viewtog:
if (++displaymode == DISP_MAX)
displaymode = 0;
displaymode = displaymode == DISP_IO ? DISP_CPU : DISP_IO;
header_text = format_header(uname_field);
display_header(true);
d_header = i_header;

View File

@ -1,7 +1,6 @@
/*-
* Top - a top users display for Berkeley Unix
*
* General (global) definitions
* $FreeBSD$
*/
@ -11,7 +10,7 @@
#include <unistd.h>
/* Number of lines of header information on the standard screen */
extern int Header_lines; /* 7 */
extern int Header_lines;
/* Maximum number of columns allowed for display */
#define MAX_COLS 512

View File

@ -124,7 +124,7 @@ itoa7(int val)
/*
* digits(val) - return number of decimal digits in val. Only works for
* non-negative numbers. If val <= 0 then digits(val) == 0.
* non-negative numbers.
*/
int __pure2
@ -319,7 +319,7 @@ format_time(long seconds)
#define NUM_STRINGS 8
char *
format_k(int amt)
format_k(long amt)
{
static char retarray[NUM_STRINGS][16];
static int index = 0;

View File

@ -19,7 +19,7 @@ int digits(int);
const char * const *argparse(char *, int *);
long percentages(int, int *, long *, long *, long *);
char *format_time(long);
char *format_k(int);
char *format_k(long);
char *format_k2(unsigned long long);
int string_index(const char *string, const char * const *array);
int find_pid(pid_t pid);