Page MenuHomeFreeBSD

top(1) - support UTF-8 display
ClosedPublic

Authored by daichi on Jun 29 2018, 8:00 AM.
Tags
None
Referenced Files
F83739280: D16058.diff
Tue, May 14, 6:33 AM
Unknown Object (File)
Wed, Apr 17, 5:31 PM
Unknown Object (File)
Wed, Apr 17, 11:24 AM
Unknown Object (File)
Wed, Apr 17, 11:19 AM
Unknown Object (File)
Wed, Apr 17, 11:15 AM
Unknown Object (File)
Feb 5 2024, 3:32 PM
Unknown Object (File)
Jan 12 2024, 7:47 PM
Unknown Object (File)
Dec 20 2023, 8:19 AM
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