mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 23:29:34 +00:00
ps: fix buglet, add microoptimization
This commit is contained in:
parent
db50647d1f
commit
6dca70a049
10
procps/ps.c
10
procps/ps.c
@ -216,18 +216,16 @@ static void format_process(const procps_status_t *ps)
|
|||||||
// POSIX: Any field need not be meaningful in all
|
// POSIX: Any field need not be meaningful in all
|
||||||
// implementations. In such a case a hyphen ( '-' )
|
// implementations. In such a case a hyphen ( '-' )
|
||||||
// should be output in place of the field value.
|
// should be output in place of the field value.
|
||||||
if (!*p) {
|
if (!p[0]) {
|
||||||
*p++ = '-';
|
p[0] = '-';
|
||||||
*p = '\0';
|
p[1] = '\0';
|
||||||
}
|
}
|
||||||
len = strlen(p);
|
len = strlen(p);
|
||||||
p += len;
|
p += len;
|
||||||
len = out[i].width - len + 1;
|
len = out[i].width - len + 1;
|
||||||
if (++i == out_cnt) /* do not pad last field */
|
if (++i == out_cnt) /* do not pad last field */
|
||||||
break;
|
break;
|
||||||
while (len--)
|
p += sprintf(p, "%*s", len, "");
|
||||||
*p++ = ' ';
|
|
||||||
*p = '\0';
|
|
||||||
}
|
}
|
||||||
printf("%.*s\n", terminal_width, buffer);
|
printf("%.*s\n", terminal_width, buffer);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user