Page MenuHomeFreeBSD

top(1) - support UTF-8 display
ClosedPublic

Authored by daichi on Jun 29 2018, 8:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 5, 5:26 PM
Unknown Object (File)
Oct 9 2024, 12:04 PM
Unknown Object (File)
Sep 27 2024, 11:16 PM
Unknown Object (File)
Sep 27 2024, 8:24 AM
Unknown Object (File)
Sep 27 2024, 8:17 AM
Unknown Object (File)
Sep 21 2024, 10:31 AM
Unknown Object (File)
Sep 9 2024, 3:14 AM
Unknown Object (File)
Sep 4 2024, 1:57 PM
Subscribers

Details

Reviewers
eadler
gnn
Summary

top(1) - support UTF-8 display

Test Plan

You need a terminal that supports UTF-8 (for example, use Terminal of MacOS and login FreeBSD-head via ssh).

on A terminal:

% export LANG=ja_JP.UTF-8
% sh
% touch 日本語のファイル
% cat - 日本語のファイル

on B terminal:

% export LANG=ja_JP.UTF-8
% /usr/bin/top -a -d 1 | grep cat

result:

original top:
% /usr/bin/top -a -d 1 | grep cat
 9688 daichi        1  20    0   12M    2M piperd   0   0:00   0.00% grep cat
 7925 daichi        1  20    0   11M    2M ttyin    1   0:00   0.00% cat - \M-f\M^W\M-%\M-f\M^\\M-,\M-h\M-*\M^^\M-c\M^A\M-.\M-c\M^C\M^U\M-c\M^B\M-!\M-c\M^B\M-$\M-c\M^C\M-+
%

patched top:
% top -a -d 1 -U daichi | grep cat
 9692 daichi        1  20    0   12M    2M piperd   1   0:00   0.00% grep cat
 7925 daichi        1  20    0   11M    2M ttyin    1   0:00   0.00% cat - 日本語のファイル
%

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

It is a bit late for me, so this is just an initial scan.

usr.bin/top/machine.c
991

please add braces here.

usr.bin/top/top.c
617–620

Perhaps use strstr and remove the magic number 5 ?

usr.bin/top/top.h
40

this should be a boolean

usr.bin/top/utils.c
338

This feels like it should be in a library, not in top(1)

356–358

this feels like a lot of duplication that could be mostly replaced by an if statement. Where did all of this come from?

Eitan's advice was reflected. Thanks Eitan.

gnn requested changes to this revision.Jun 30 2018, 7:12 AM
gnn added inline comments.
usr.bin/top/display.c
1273

Please move this, and all other else statements to be on the same line as the previous enclosing brace

if (foo) {
} else if () {
} else if () {
} else {
}

This revision now requires changes to proceed.Jun 30 2018, 7:12 AM

George's advice was reflected. Thanks George.

This revision is now accepted and ready to land.Jun 30 2018, 3:08 PM
kbowling added a subscriber: kbowling.

This was commited in rS335836