From 8ff0dcbd4b70b2f80ca86200b11033766ec731c5 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Fri, 1 Jan 2021 00:00:00 -0600 Subject: [PATCH] top: tweak cmd/cmdline logic for a possible bad locale Since this master library isn't quite as sophisticated as the newlib version, this patch will protect against the possibility of multibyte characters in a program's name combined with some locale without UTF-8 encoding. [ it is better to treat the COMMAND column length as ] [ more than what's actually printed than to have the ] [ line overflow & corrupt the remaining screen lines ] Signed-off-by: Jim Warner --- top/top.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/top/top.c b/top/top.c index b07ea284..2ec63573 100644 --- a/top/top.c +++ b/top/top.c @@ -6191,7 +6191,10 @@ static const char *task_show (const WIN_t *q, const int idx) { varUTF8(p->cgroup[0]); break; case EU_CMD: - varUTF8(forest_display(q, p)); + if (CHKw(q, Show_CMDLIN)) + varUTF8(forest_display(q, p)) + else + makeVAR(forest_display(q, p)); break; case EU_COD: cp = scale_mem(S, pages2K(p->trs), W, Jn);