From: Denis Vlasenko Date: Mon, 18 Dec 2006 14:20:01 +0000 (-0000) Subject: ps: fix buglet, add microoptimization X-Git-Tag: 1_4_0~231 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6dca70a04908f190c63ca76853ec2e7e0ea20c06;p=oweals%2Fbusybox.git ps: fix buglet, add microoptimization --- 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) // 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); }