diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-18 14:20:01 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-18 14:20:01 +0000 |
commit | 6dca70a04908f190c63ca76853ec2e7e0ea20c06 (patch) | |
tree | 548564d3dc1619c6608857e8257e9f9a070ac6aa | |
parent | db50647d1f55d9d83dd1ffe8f2318e98e2d50a86 (diff) | |
download | busybox-w32-6dca70a04908f190c63ca76853ec2e7e0ea20c06.tar.gz busybox-w32-6dca70a04908f190c63ca76853ec2e7e0ea20c06.tar.bz2 busybox-w32-6dca70a04908f190c63ca76853ec2e7e0ea20c06.zip |
ps: fix buglet, add microoptimization
-rw-r--r-- | procps/ps.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/procps/ps.c b/procps/ps.c index e18bd2a58..12f6b65d1 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -216,18 +216,16 @@ static void format_process(const procps_status_t *ps) | |||
216 | // POSIX: Any field need not be meaningful in all | 216 | // POSIX: Any field need not be meaningful in all |
217 | // implementations. In such a case a hyphen ( '-' ) | 217 | // implementations. In such a case a hyphen ( '-' ) |
218 | // should be output in place of the field value. | 218 | // should be output in place of the field value. |
219 | if (!*p) { | 219 | if (!p[0]) { |
220 | *p++ = '-'; | 220 | p[0] = '-'; |
221 | *p = '\0'; | 221 | p[1] = '\0'; |
222 | } | 222 | } |
223 | len = strlen(p); | 223 | len = strlen(p); |
224 | p += len; | 224 | p += len; |
225 | len = out[i].width - len + 1; | 225 | len = out[i].width - len + 1; |
226 | if (++i == out_cnt) /* do not pad last field */ | 226 | if (++i == out_cnt) /* do not pad last field */ |
227 | break; | 227 | break; |
228 | while (len--) | 228 | p += sprintf(p, "%*s", len, ""); |
229 | *p++ = ' '; | ||
230 | *p = '\0'; | ||
231 | } | 229 | } |
232 | printf("%.*s\n", terminal_width, buffer); | 230 | printf("%.*s\n", terminal_width, buffer); |
233 | } | 231 | } |