Page MenuHomeFreeBSD

top(1): support multibyte characters in ARGV array depending on LC_CTYPE, not limited to UTF-8
AcceptedPublic

Authored by daichi on Jul 10 2018, 4:06 AM.

Details

Summary
Test Plan

You need a terminal that supports multibyte characters (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 - 日本語のファイル
%

Or check with other locales.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

daichi created this revision.Jul 10 2018, 4:06 AM
hrs requested changes to this revision.Jul 10 2018, 8:54 AM

IMHO strvisx(3) in machine.c should have a VIS_OCTAL flag as in my original submission because meta char encoding of strvisx(3), which uses iscntrl(3), does not make sense for most of multibyte encodings. Displaying characters not for the current locale in octal (or hexadecimal) number looks more intuitive to me.

This revision now requires changes to proceed.Jul 10 2018, 8:54 AM
daichi updated this revision to Diff 45105.Jul 10 2018, 9:08 AM

Updated patches according to hrs' advice. Thank you.

hrs accepted this revision.Jul 11 2018, 11:14 AM

This is my submission, so I will leave someone else to do further review of this change. Please do not count my "accept revision" as an immediate approval.

I think VIS_OCTAL should be documented at least in the commit log because it is a user-visible change, and multibyte character handling should be documented in the manual page, too.

This revision is now accepted and ready to land.Jul 11 2018, 11:14 AM
gnn accepted this revision.Aug 20 2018, 9:29 AM

LGTM