Page MenuHomeFreeBSD

top(1): support multibyte characters in command names (ARGV array) depending on locale
ClosedPublic

Authored by daichi on Jul 10 2018, 4:06 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 24, 2:59 AM
Unknown Object (File)
Oct 22 2024, 6:55 PM
Unknown Object (File)
Sep 28 2024, 4:57 PM
Unknown Object (File)
Sep 26 2024, 9:49 PM
Unknown Object (File)
Sep 26 2024, 4:53 PM
Unknown Object (File)
Sep 24 2024, 8:16 AM
Unknown Object (File)
Sep 23 2024, 3:14 AM
Unknown Object (File)
Sep 22 2024, 11:15 PM
Subscribers

Details

Reviewers
hrs
gnn
jilles
eadler
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
manpages
Commits
rS352558: top(1): support multibyte characters in command names (ARGV array)
Summary

top(1): support multibyte characters in command names (ARGV array) depending on locale.

  • add setlocale()
  • remove printable() function
  • add VIS_OCTAL and VIS_SAFE to the flag of strvisx() to display non-printable characters that do not use C-style backslash sequences in three digit octal sequence, or remove it

This change allows multibyte characters to be displayed according to locale. If it is recognized as a non-display character according to the locale, it is displayed in three digit octal sequence.

submitted by: hrs

Reference:
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165751.html
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165766.html
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165833.html
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165846.html
https://www.mail-archive.com/svn-src-all@freebsd.org/msg165891.html

Test Plan

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

on terminal A:

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

on terminal B:

% export LANG=ja_JP.UTF-8
% /usr/bin/top -a -d 1 1000 | 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 1000 | 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
Tests Skipped

Event Timeline

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

Updated patches according to hrs' advice. Thank you.

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

Update patch to HEAD-2019-09-20

This revision now requires review to proceed.Sep 20 2019, 8:35 AM

Added explanation about locale display in manual according to hrs advice.

daichi retitled this revision from top(1): support multibyte characters in ARGV array depending on LC_CTYPE, not limited to UTF-8 to top(1): support multibyte characters in command names(ARGV array) depending on locale, not limited to UTF-8.Sep 20 2019, 9:04 AM
daichi retitled this revision from top(1): support multibyte characters in command names(ARGV array) depending on locale, not limited to UTF-8 to top(1): support multibyte characters in command names(ARGV array) depending on locale.
daichi retitled this revision from top(1): support multibyte characters in command names(ARGV array) depending on locale to top(1): support multibyte characters in command names (ARGV array) depending on locale.Sep 20 2019, 9:06 AM
daichi edited the summary of this revision. (Show Details)

Add VIS_SAFE to strvisx(), adviced by hrs

Owners added a reviewer: Restricted Owners Package.Sep 20 2019, 12:46 PM

There's a minor manpage style issue.

Please remember to bump Dd when committing!

usr.bin/top/top.1
196 ↗(On Diff #62344)

New sentences should start on a new line.

Changed man page style and bumped Dd according to 0mp advice.

This revision was not accepted when it landed; it landed in state Needs Review.Sep 20 2019, 5:37 PM
This revision was automatically updated to reflect the committed changes.