From owner-svn-src-all@freebsd.org Sun Jun 7 08:21:20 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B37A434C6D9; Sun, 7 Jun 2020 08:21:20 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49fq8w4Lx5z49t3; Sun, 7 Jun 2020 08:21:20 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 766CAFEE7; Sun, 7 Jun 2020 08:21:20 +0000 (UTC) (envelope-from yuripv@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0578LKiu098670; Sun, 7 Jun 2020 08:21:20 GMT (envelope-from yuripv@FreeBSD.org) Received: (from yuripv@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0578LJlv098668; Sun, 7 Jun 2020 08:21:19 GMT (envelope-from yuripv@FreeBSD.org) Message-Id: <202006070821.0578LJlv098668@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: yuripv set sender to yuripv@FreeBSD.org using -f From: Yuri Pankov Date: Sun, 7 Jun 2020 08:21:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361887 - head/bin/ps X-SVN-Group: head X-SVN-Commit-Author: yuripv X-SVN-Commit-Paths: head/bin/ps X-SVN-Commit-Revision: 361887 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jun 2020 08:21:20 -0000 Author: yuripv Date: Sun Jun 7 08:21:19 2020 New Revision: 361887 URL: https://svnweb.freebsd.org/changeset/base/361887 Log: ps: use %hs instead of %s format specifiers Use %hs (locale-based encoding) instead of %s (UTF-8) format for strings that are expected to be in current locale encoding (date/time, process names/argument list). PR: 241491 Reviewed by: phil Differential Revision: https://reviews.freebsd.org/D22160 Modified: head/bin/ps/keyword.c head/bin/ps/print.c head/bin/ps/ps.c Modified: head/bin/ps/keyword.c ============================================================================== --- head/bin/ps/keyword.c Sun Jun 7 05:08:44 2020 (r361886) +++ head/bin/ps/keyword.c Sun Jun 7 08:21:19 2020 (r361887) @@ -254,7 +254,7 @@ showkey(void) i = len; sep = "\n"; } - xo_emit("{P:/%s}{l:key/%s}", sep, p); + xo_emit("{P:/%hs}{l:key/%hs}", sep, p); sep = " "; } xo_emit("\n"); Modified: head/bin/ps/print.c ============================================================================== --- head/bin/ps/print.c Sun Jun 7 05:08:44 2020 (r361886) +++ head/bin/ps/print.c Sun Jun 7 08:21:19 2020 (r361887) @@ -89,11 +89,11 @@ printheader(void) v = vent->var; if (v->flag & LJUST) { if (STAILQ_NEXT(vent, next_ve) == NULL) /* last one */ - xo_emit("{T:/%s}", vent->header); + xo_emit("{T:/%hs}", vent->header); else - xo_emit("{T:/%-*s}", v->width, vent->header); + xo_emit("{T:/%-*hs}", v->width, vent->header); } else - xo_emit("{T:/%*s}", v->width, vent->header); + xo_emit("{T:/%*hs}", v->width, vent->header); if (STAILQ_NEXT(vent, next_ve) != NULL) xo_emit("{P: }"); } Modified: head/bin/ps/ps.c ============================================================================== --- head/bin/ps/ps.c Sun Jun 7 05:08:44 2020 (r361886) +++ head/bin/ps/ps.c Sun Jun 7 08:21:19 2020 (r361887) @@ -192,6 +192,7 @@ main(int argc, char *argv[]) char fmtbuf[_POSIX2_LINE_MAX]; (void) setlocale(LC_ALL, ""); + xo_no_setlocale(); time(&now); /* Used by routines in print.c. */ /* @@ -696,7 +697,7 @@ main(int argc, char *argv[]) fwidthmin = (xo_get_style(NULL) != XO_STYLE_TEXT || (STAILQ_NEXT(vent, next_ve) == NULL && (vent->var->flag & LJUST))) ? 0 : vent->var->width; - snprintf(fmtbuf, sizeof(fmtbuf), "{:%s/%%%s%d..%ds}", + snprintf(fmtbuf, sizeof(fmtbuf), "{:%s/%%%s%d..%dhs}", vent->var->field ? vent->var->field : vent->var->name, (vent->var->flag & LJUST) ? "-" : "", fwidthmin, fwidthmax);