From 31a85510fa4479db8c9aeb2fb7faeccf0f5b48a1 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 5 Mar 2016 07:44:31 +0000 Subject: 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(). --- usr.bin/tmux/tmux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'usr.bin/tmux/tmux.c') 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 @@ -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 == '-') -- cgit v1.2.3-59-g8ed1b