aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-06-10 17:58:56 -0500
committerRob Landley <rob@landley.net>2016-06-10 17:58:56 -0500
commitd32309a3c0014e7e6c3d2a2fcd5ed9fb19cb6585 (patch)
tree1c402dd32a12a23de1d064e4e43331473990d218
parent082dadce554e8a37eb34ea1f9a727feadea04073 (diff)
downloadtoybox-d32309a3c0014e7e6c3d2a2fcd5ed9fb19cb6585.tar.gz
Revert commit e02e41373ea3, we're always initializing the TNAME string
field (that's the ptb/tb switching in get_ps) so it's never blank, so this doesn't trigger. (Conditionally initializing it would save runtime memory, but at the expense of more complex code.)
-rw-r--r--toys/posix/ps.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 9402b779..74f8954a 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -443,24 +443,13 @@ static char *string_field(struct carveup *tb, struct strawberry *field)
sl *= -1;
// First string slot has offset 0, others are offset[-slot-2]
if (--sl) out += tb->offset[--sl];
- // If TNAME is blank, show ARGS instead
- if (which==PS_ARGS && !*out)
- out = tb->str+tb->offset[-2-typos[which = PS_ARGS].slot];
if (which==PS_ARGS || which==PS_NAME) {
- int i, j;
+ int i;
s = out;
for (i = 0; (which==PS_ARGS) ? i < slot[SLOT_argv0len] : out[i]; i++)
if (out[i] == '/') s = out+i+1;
- i = s - out;
out = s;
- if (which != field->which) {
- j = slot[SLOT_argv0len]-i;
- if (j > 259) j = 259;
- memcpy(buf, out+i, j);
- buf[j] = 0;
- out = buf;
- }
}
if (which>=PS_COMM && !*out) sprintf(out = buf, "[%s]", tb->str);