From owner-svn-src-head@freebsd.org Sun Jul 1 17:08:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27345FD00EB; Sun, 1 Jul 2018 17:08:28 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-it0-f52.google.com (mail-it0-f52.google.com [209.85.214.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9A83475F50; Sun, 1 Jul 2018 17:08:27 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-it0-f52.google.com with SMTP id o5-v6so8134511itc.1; Sun, 01 Jul 2018 10:08:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=B+WwLYvxiX8E0QyhilqYrnZ2XXmy9po9CTH3KlcJxFI=; b=RhiVcaxkXQrzy8gWbLG96tGhuM+jAycrXTaOmZq/59IslQHndcSTJamIgXIsn69Q3r WGis6ozh4wL5172BSBoEb7iXz9bfYe2GFzS319IgFzTetpRzBW2GfmhSNvLYDIPeC/21 7rVM0HBtn4VBTquAwxxNR5MBoRtlkPkyxa/A4qwsfMM7IYTpo7i54f4G/RQmKcpl7IP3 ULVpteUOeDqp8G4KXRcvVdE2uz7dXkPQM4cjZ+ZKwEc/INOFDUF/n3HdtigCjfpsHFIs rR7g5bFjdYqmuRHJi7uHpQ/QKcjLGCy0ZJwTi1NhV+22tOOW81lrYv/facE2epD9kJzZ OA4g== X-Gm-Message-State: APt69E2Mgb1C6pQqBg1cOfX3l15Y7F8W5HxXgzcuR4HTyqTRuIGFOqOd 6IeKREwviYOyE++VpDmkZj37Sjvt X-Google-Smtp-Source: AAOMgpdPaKzwzMEAnNM8G318VidYMOx3eZHtj56o1px9aGk04jQ8xk38JD9oOCKOmQ7v1XS4BtsG8w== X-Received: by 2002:a24:2495:: with SMTP id f143-v6mr7642654ita.37.1530464900777; Sun, 01 Jul 2018 10:08:20 -0700 (PDT) Received: from mail-io0-f169.google.com (mail-io0-f169.google.com. [209.85.223.169]) by smtp.gmail.com with ESMTPSA id w4-v6sm1326199itb.31.2018.07.01.10.08.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 10:08:20 -0700 (PDT) Received: by mail-io0-f169.google.com with SMTP id t135-v6so12740838iof.7; Sun, 01 Jul 2018 10:08:19 -0700 (PDT) X-Received: by 2002:a6b:b0c5:: with SMTP id z188-v6mr8595982ioe.220.1530464899440; Sun, 01 Jul 2018 10:08:19 -0700 (PDT) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 2002:a02:7e0a:0:0:0:0:0 with HTTP; Sun, 1 Jul 2018 10:08:18 -0700 (PDT) In-Reply-To: <201807010532.w615W44e042172@repo.freebsd.org> References: <201807010532.w615W44e042172@repo.freebsd.org> From: Conrad Meyer Date: Sun, 1 Jul 2018 10:08:18 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r335836 - head/usr.bin/top To: Daichi GOTO Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jul 2018 17:08:28 -0000 Hi Daichi, On Sat, Jun 30, 2018 at 10:32 PM, Daichi GOTO 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. (Also, the patch in phabricator does not seem to match what was committed.) Best, Conrad