diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-04-27 09:36:26 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2016-04-27 09:36:26 +0000 |
commit | 4cfd93ac03c7fe5c36c15f7693b4df0aa7ed288f (patch) | |
tree | 9b6dd78c5a1277a7ed4cfbe74a8bc30cbe3c8865 | |
parent | 610fa70ca6a50bd5a55ea134dccfea8fb312e63b (diff) |
Loads of platforms appear to have old or broken Unicode character type
information and are missing widths for relatively common Unicode
characters (so mbtowc() works, but wcwidth() fails). So if wcwidth()
returns -1, assume a width of 1 instead of ignoring the character.
-rw-r--r-- | usr.bin/tmux/utf8.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/tmux/utf8.c b/usr.bin/tmux/utf8.c index 7c6845f0e93..9bffbae0481 100644 --- a/usr.bin/tmux/utf8.c +++ b/usr.bin/tmux/utf8.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utf8.c,v 1.30 2016/04/26 07:33:36 nicm Exp $ */ +/* $OpenBSD: utf8.c,v 1.31 2016/04/27 09:36:25 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -119,6 +119,14 @@ utf8_width(wchar_t wc) width = wcwidth(wc); if (width < 0 || width > 0xff) { log_debug("Unicode %04x, wcwidth() %d", wc, width); + + /* + * Many platforms have no width for relatively common + * characters (wcwidth() returns -1); assume width 1 in this + * case and hope for the best. + */ + if (width < 0) + return (1); return (-1); } return (width); |