summaryrefslogtreecommitdiff
path: root/procps/ps.c
diff options
context:
space:
mode:
authorDenis Vlasenko2006-12-18 14:20:01 +0000
committerDenis Vlasenko2006-12-18 14:20:01 +0000
commit6dca70a04908f190c63ca76853ec2e7e0ea20c06 (patch)
tree548564d3dc1619c6608857e8257e9f9a070ac6aa /procps/ps.c
parentdb50647d1f55d9d83dd1ffe8f2318e98e2d50a86 (diff)
downloadbusybox-6dca70a04908f190c63ca76853ec2e7e0ea20c06.zip
busybox-6dca70a04908f190c63ca76853ec2e7e0ea20c06.tar.gz
ps: fix buglet, add microoptimization
Diffstat (limited to 'procps/ps.c')
-rw-r--r--procps/ps.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/procps/ps.c b/procps/ps.c
index e18bd2a..12f6b65 100644
--- a/procps/ps.c
+++ b/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
// implementations. In such a case a hyphen ( '-' )
// should be output in place of the field value.
- if (!*p) {
- *p++ = '-';
- *p = '\0';
+ if (!p[0]) {
+ p[0] = '-';
+ p[1] = '\0';
}
len = strlen(p);
p += len;
len = out[i].width - len + 1;
if (++i == out_cnt) /* do not pad last field */
break;
- while (len--)
- *p++ = ' ';
- *p = '\0';
+ p += sprintf(p, "%*s", len, "");
}
printf("%.*s\n", terminal_width, buffer);
}