summaryrefslogtreecommitdiffstats
path: root/utf8.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2016-04-29 12:47:15 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2016-04-29 12:47:15 +0100
commit65e4c57d3a554940ed5cada6dfeff403ae8d9572 (patch)
treef24900b7b843fc1732ab65f7a235b524ac11e828 /utf8.c
parenta9d501e975ca2ecbcb79262678d2f17694b58856 (diff)
Only assume width 1 when wcwidth() returns -1 on non-OpenBSD platforms.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index 54cea671..421c0fea 100644
--- a/utf8.c
+++ b/utf8.c
@@ -118,6 +118,20 @@ utf8_width(wchar_t wc)
width = wcwidth(wc);
if (width < 0 || width > 0xff) {
log_debug("Unicode %04x, wcwidth() %d", wc, width);
+
+#ifndef __OpenBSD__
+ /*
+ * Many platforms (particularly and inevitably OS X) have no
+ * width for relatively common characters (wcwidth() returns
+ * -1); assume width 1 in this case. This will be wrong for
+ * genuinely nonprintable characters, but they should be
+ * rare. We may pass through stuff that ideally we would block,
+ * but this is no worse than sending the same to the terminal
+ * without tmux.
+ */
+ if (width < 0)
+ return (1);
+#endif
return (-1);
}
return (width);