summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-06-05 07:22:23 +0000
committernicm <nicm@openbsd.org>2009-06-05 07:22:23 +0000
commit1c051c6deb925a80d6223de221c4528f9c6bdd55 (patch)
treeb007049358da63f142ab5943c3886267ea7b5452 /usr.bin/tmux/tmux.c
parentfix a quote from GBS; (diff)
downloadwireguard-openbsd-1c051c6deb925a80d6223de221c4528f9c6bdd55.tar.xz
wireguard-openbsd-1c051c6deb925a80d6223de221c4528f9c6bdd55.zip
Check the first of LC_CTYPE, LC_ALL and LANG, rather than just the last, when
trying to decide about UTF-8, and use strcasestr. Reported by Geert Hendrickx.
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index af348e5344e..a6b4df134e6 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.7 2009/06/04 21:56:14 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.8 2009/06/05 07:22:23 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -326,12 +326,17 @@ main(int argc, char **argv)
if (!(flags & IDENTIFY_UTF8)) {
/*
- * If the user has set LANG to contain UTF-8, it is a safe
+ * If the user has set whichever of LC_ALL, LC_CTYPE or LANG
+ * exist (in that order) to contain UTF-8, it is a safe
* assumption that either they are using a UTF-8 terminal, or
* if not they know that output from UTF-8-capable programs may
* be wrong.
*/
- if ((s = getenv("LANG")) != NULL && strstr(s, "UTF-8") != NULL)
+ if ((s = getenv("LC_CTYPE")) == NULL) {
+ if ((s = getenv("LC_ALL")) == NULL)
+ s = getenv("LANG");
+ }
+ if (s != NULL && strcasestr(s, "UTF-8") != NULL)
flags |= IDENTIFY_UTF8;
}