From 266ac9daaa8d5da187af3a48951d0670e2b7b5b8 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Wed, 29 Apr 2026 17:55:17 -0500 Subject: [PATCH] Mark Hansen had a good suggestion: init the counter to the offset value rather than subtracting it from each test. --- toys/posix/ps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/toys/posix/ps.c b/toys/posix/ps.c index 6b0e418c..582f76cd 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -1724,11 +1724,11 @@ static void top_common( lines = header_line(lines, 0); // print line of header labels for currently displayed fields get_headers(TT.fields, pos = toybuf, sizeof(toybuf)); - for (i = 0; *pos; i++) { + for (i = TT.scroll; *pos; i++) { while (isspace(*pos)) pos++; - if (pos!=toybuf && i==TT.sortpos-TT.scroll) pos[-1] = '['; + if (pos!=toybuf && i==TT.sortpos) pos[-1] = '['; while (*pos && !isspace(*pos)) pos++; - if (*pos && i==TT.sortpos-TT.scroll) *pos++ = ']'; + if (*pos && i==TT.sortpos) *pos++ = ']'; } if (FLAG(b)) while (isspace(*(pos-1))) --pos; *pos = 0; -- 2.39.5