summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2016-03-05 16:08:38 +0000
committernicm <nicm@openbsd.org>2016-03-05 16:08:38 +0000
commit3b05404caa58e1bf3b6e4c9bf7641fe80c998e76 (patch)
treeeb7ebc9aea5c00b77c914b3b805d8f374fde5f7a /usr.bin/tmux/tmux.c
parentupdate to unbound 1.5.8, ok florian@ jung@ (diff)
downloadwireguard-openbsd-3b05404caa58e1bf3b6e4c9bf7641fe80c998e76.tar.xz
wireguard-openbsd-3b05404caa58e1bf3b6e4c9bf7641fe80c998e76.zip
If setlocale("en_US.UTF-8") succeeds, then don't do the check for UTF-8
locale since if it isn't UTF-8 the system is broken anyway. If it fails, try "" and check for UTF-8 with nl_langinfo(CODESET) rather than wcwidth(). Based on a diff from schwarze@, nl_langinfo also suggested by stsp@.
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index e4685b7f657..e9d4c2ed219 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.167 2016/03/05 07:44:31 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.168 2016/03/05 16:08:38 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -24,6 +24,7 @@
#include <event.h>
#include <fcntl.h>
#include <getopt.h>
+#include <langinfo.h>
#include <locale.h>
#include <paths.h>
#include <pwd.h>
@@ -188,10 +189,14 @@ main(int argc, char **argv)
const char *s;
int opt, flags, keys;
- 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");
+ if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL) {
+ if (setlocale(LC_CTYPE, "") == NULL)
+ errx(1, "invalid LC_ALL, LC_CTYPE or LANG");
+ s = nl_langinfo(CODESET);
+ if (strcasecmp(s, "UTF-8") != 0 &&
+ strcasecmp(s, "UTF8") != 0)
+ errx(1, "need UTF-8 locale (LC_CTYPE) but have %s", s);
+ }
setlocale(LC_TIME, "");
tzset();