summaryrefslogtreecommitdiff
path: root/bin/ps/ps.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2016-01-10 14:04:17 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2016-01-10 14:04:17 +0000
commit1ff71698b00a0496a82edb13ea27e66fe35c1677 (patch)
tree972972c21b733bc95835c67cdda9979eec3f2c63 /bin/ps/ps.c
parent88a702d55b47acbe595220ed818f39dff08ffe09 (diff)
UTF-8 support:
In a UTF-8 locale, columnate correctly and replace valid, but non- printable characters with the Unicode replacement character U+FFFD. No change in the C/POSIX locale, and no change for invalid bytes. Grand total, the code becomes shorter by almost 30 lines. Feedback from czarkoff@, OK millert@.
Diffstat (limited to 'bin/ps/ps.c')
-rw-r--r--bin/ps/ps.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 93e46d783d1..a7c4e43c812 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ps.c,v 1.68 2015/11/11 03:20:02 deraadt Exp $ */
+/* $OpenBSD: ps.c,v 1.69 2016/01/10 14:04:16 schwarze Exp $ */
/* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */
/*-
@@ -44,6 +44,7 @@
#include <errno.h>
#include <fcntl.h>
#include <kvm.h>
+#include <locale.h>
#include <nlist.h>
#include <paths.h>
#include <pwd.h>
@@ -99,6 +100,8 @@ main(int argc, char *argv[])
int prtheader, showthreads, wflag, kflag, what, Uflag, xflg;
char *nlistf, *memf, *swapf, *cols, errbuf[_POSIX2_LINE_MAX];
+ setlocale(LC_CTYPE, "");
+
if ((cols = getenv("COLUMNS")) != NULL && *cols != '\0') {
const char *errstr;