Date: Mon, 02 Jul 2018 17:30:24 +0900 From: =?utf-8?B?5b6M6Jek5aSn5Zyw?= <daichigoto@icloud.com> To: Conrad Meyer <cem@freebsd.org> Cc: Daichi GOTO <daichi@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r335836 - head/usr.bin/top Message-ID: <CC4D7694-D0E1-43A8-8B25-F0717D7AB734@icloud.com> In-Reply-To: <CAG6CVpXvic6y6VLEjBzxFtdQC=6b_%2BC2CmEvpMssgYEahAZhOQ@mail.gmail.com> References: <201807010532.w615W44e042172@repo.freebsd.org> <CAG6CVpXvic6y6VLEjBzxFtdQC=6b_%2BC2CmEvpMssgYEahAZhOQ@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
> 2018/07/02 2:08、Conrad Meyer <cem@freebsd.org>のメール: > > Hi Daichi, > > On Sat, Jun 30, 2018 at 10:32 PM, Daichi GOTO <daichi@freebsd.org> wrote: >> Author: daichi >> Date: Sun Jul 1 05:32:03 2018 >> New Revision: 335836 >> URL: https://svnweb.freebsd.org/changeset/base/335836 >> >> Log: >> top(1) - support UTF-8 display >> >> ... >> ============================================================================== >> --- head/usr.bin/top/display.c Sun Jul 1 01:56:40 2018 (r335835) >> +++ head/usr.bin/top/display.c Sun Jul 1 05:32:03 2018 (r335836) >> @@ -1258,19 +1258,43 @@ line_update(char *old, char *new, int start, int line) >> char * >> printable(char str[]) >> { >> - char *ptr; >> - char ch; >> + char *ptr; >> + char ch; >> >> - ptr = str; >> - while ((ch = *ptr) != '\0') >> - { >> - if (!isprint(ch)) >> - { >> - *ptr = '?'; >> + ptr = str; >> + if (utf8flag) { >> + while ((ch = *ptr) != '\0') { >> + if (0x00 == (0x80 & ch)) { >> + if (!isprint(ch)) { >> + *ptr = '?'; >> + } >> + ++ptr; >> + } else if (0xC0 == (0xE0 & ch)) { >> + ++ptr; >> + if ('\0' != *ptr) ++ptr; >> + } else if (0xE0 == (0xF0 & ch)) { >> + ++ptr; >> + if ('\0' != *ptr) ++ptr; >> + if ('\0' != *ptr) ++ptr; >> + } else if (0xF0 == (0xF8 & ch)) { >> + ++ptr; >> + if ('\0' != *ptr) ++ptr; >> + if ('\0' != *ptr) ++ptr; >> + if ('\0' != *ptr) ++ptr; >> + } else { >> + *ptr = '?'; >> + ++ptr; >> + } >> + } >> + } else { >> + while ((ch = *ptr) != '\0') { >> + if (!isprint(ch)) { >> + *ptr = '?'; >> + } >> + ptr++; >> + } >> } > > > I don't think code to decode UTF-8 belongs in top(1). I don't know > what the goal of this routine is, but I doubt this is the right way to > accomplish it. > > For the strvisx portion it seems like support should be rolled into > libc instead. Hi Conrad, The purpose is to display UTF-8 string. Certainly, you are right. In the end I think I should support it with libc. However, I think that it is a problem that UTF-8 can not be used with the top command for a long period of time. Although it may be transient, I think that keeping it to work is not that bad idea. Best regards, Daichi > (Also, the patch in phabricator does not seem to match what was committed.) > > Best, > Conrad >help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CC4D7694-D0E1-43A8-8B25-F0717D7AB734>
