top: make 's' display easier to understand

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2010-03-04 12:50:59 +01:00
parent 197202d435
commit 917693b5b3

View File

@ -701,7 +701,7 @@ static char *grab_number(char *str, const char *match, unsigned sz)
{ {
if (strncmp(str, match, sz) == 0) { if (strncmp(str, match, sz) == 0) {
str = skip_whitespace(str + sz); str = skip_whitespace(str + sz);
(skip_non_whitespace(str))[1] = '\0'; (skip_non_whitespace(str))[0] = '\0';
return xstrdup(str); return xstrdup(str);
} }
return NULL; return NULL;
@ -770,17 +770,17 @@ static void display_topmem_header(int scr_width, int *lines_rem_p)
#define S(s) (s ? s : "0") #define S(s) (s ? s : "0")
snprintf(linebuf, sizeof(linebuf), snprintf(linebuf, sizeof(linebuf),
"Mem %stotal %sanon %smap %sfree", "Mem total:%s anon:%s map:%s free:%s",
S(total), S(anon), S(map), S(mfree)); S(total), S(anon), S(map), S(mfree));
printf(OPT_BATCH_MODE ? "%.*s\n" : "\e[H\e[J%.*s\n", scr_width, linebuf); printf(OPT_BATCH_MODE ? "%.*s\n" : "\e[H\e[J%.*s\n", scr_width, linebuf);
snprintf(linebuf, sizeof(linebuf), snprintf(linebuf, sizeof(linebuf),
" %sslab %sbuf %scache %sdirty %swrite", " slab:%s buf:%s cache:%s dirty:%s write:%s",
S(slab), S(buf), S(cache), S(dirty), S(mwrite)); S(slab), S(buf), S(cache), S(dirty), S(mwrite));
printf("%.*s\n", scr_width, linebuf); printf("%.*s\n", scr_width, linebuf);
snprintf(linebuf, sizeof(linebuf), snprintf(linebuf, sizeof(linebuf),
"Swap %stotal %sfree", // TODO: % used? "Swap total:%s free:%s", // TODO: % used?
S(swaptotal), S(swapfree)); S(swaptotal), S(swapfree));
printf("%.*s\n", scr_width, linebuf); printf("%.*s\n", scr_width, linebuf);