diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-06-25 15:59:27 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2009-06-25 15:59:27 +0000 |
commit | 6f4600c533d370c6020835c786ebedaed00fcaf0 (patch) | |
tree | c457721219874a04c57ebc004734f80b91f33d8d | |
parent | fbcee9f114bb42810ee824c2bc1bbe4cd4a7a5b2 (diff) | |
download | rtmux-6f4600c533d370c6020835c786ebedaed00fcaf0.tar.gz rtmux-6f4600c533d370c6020835c786ebedaed00fcaf0.tar.bz2 rtmux-6f4600c533d370c6020835c786ebedaed00fcaf0.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.
-rw-r--r-- | tmux.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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> @@ -342,12 +342,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; } |