If ws_col is zero just dump the entire buffer

This commit is contained in:
sin 2013-09-25 12:10:46 +01:00
parent efe687ef94
commit 921631a3a9
1 changed files with 8 additions and 2 deletions

10
ps.c
View File

@ -127,7 +127,10 @@ psout(struct procstat *ps)
snprintf(buf, sizeof(buf), "%5d %-6s %02u:%02u:%02u %s", ps->pid, ttystr,
sutime / 3600, (sutime % 3600) / 60, sutime % 60,
ps->comm);
printf("%.*s\n", w.ws_col, buf);
if (w.ws_col)
printf("%.*s\n", w.ws_col, buf);
else
printf("%s\n", buf);
} else {
errno = 0;
pw = getpwuid(pstatus.uid);
@ -155,7 +158,10 @@ psout(struct procstat *ps)
sutime / 3600, (sutime % 3600) / 60, sutime % 60,
(cmd == ps->comm) ? "[" : "", cmd,
(cmd == ps->comm) ? "]" : "");
printf("%.*s\n", w.ws_col, buf);
if (w.ws_col)
printf("%.*s\n", w.ws_col, buf);
else
printf("%s\n", buf);
}
free(ttystr);
}