summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-03-05 07:44:31 +0000
committernicm <nicm@openbsd.org>2016-03-05 07:44:31 +0000
commit31a85510fa4479db8c9aeb2fb7faeccf0f5b48a1 (patch)
tree671e5c2c8aa1453f894e4c91aec2edd6098aee83 /usr.bin/tmux/tmux.c
parentmirror memset changes to ber.c made in ldapd (these 3 daemons (diff)
downloadwireguard-openbsd-31a85510fa4479db8c9aeb2fb7faeccf0f5b48a1.tar.xz
wireguard-openbsd-31a85510fa4479db8c9aeb2fb7faeccf0f5b48a1.zip
Although we always have en_US.UTF-8 on OpenBSD, some platforms do not,
so fall back to setlocale(LC_CTYPE, ""). tmux requires a UTF-8 locale, so check with wcwidth() on a UTF-8 character after setlocale().
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index 2c86f991bbd..e4685b7f657 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.166 2016/03/01 12:02:54 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.167 2016/03/05 07:44:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -188,9 +188,12 @@ main(int argc, char **argv)
const char *s;
int opt, flags, keys;
- setlocale(LC_CTYPE, "en_US.UTF-8");
- setlocale(LC_TIME, "");
+ if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL)
+ setlocale(LC_CTYPE, "");
+ if (wcwidth(0xfffd) != 1)
+ errx(1, "no UTF-8 locale; please set LC_CTYPE");
+ setlocale(LC_TIME, "");
tzset();
if (**argv == '-')