Lines 1-34
Link Here
|
1 |
commit 65e4c57d3a554940ed5cada6dfeff403ae8d9572 |
|
|
2 |
Author: Nicholas Marriott <nicholas.marriott@gmail.com> |
3 |
Date: 2016-04-29 12:47:15 +0100 |
4 |
|
5 |
Only assume width 1 when wcwidth() returns -1 on non-OpenBSD platforms. |
6 |
|
7 |
--- utf8.c.orig 2016-03-02 18:29:06 UTC |
8 |
+++ utf8.c |
9 |
@@ -115,8 +115,24 @@ utf8_width(wchar_t wc) |
10 |
int width; |
11 |
|
12 |
width = wcwidth(wc); |
13 |
- if (width < 0 || width > 0xff) |
14 |
+ if (width < 0 || width > 0xff) { |
15 |
+ log_debug("Unicode %04x, wcwidth() %d", wc, width); |
16 |
+ |
17 |
+#ifndef __OpenBSD__ |
18 |
+ /* |
19 |
+ * Many platforms (particularly and inevitably OS X) have no |
20 |
+ * width for relatively common characters (wcwidth() returns |
21 |
+ * -1); assume width 1 in this case. This will be wrong for |
22 |
+ * genuinely nonprintable characters, but they should be |
23 |
+ * rare. We may pass through stuff that ideally we would block, |
24 |
+ * but this is no worse than sending the same to the terminal |
25 |
+ * without tmux. |
26 |
+ */ |
27 |
+ if (width < 0) |
28 |
+ return (1); |
29 |
+#endif |
30 |
return (-1); |
31 |
+ } |
32 |
return (width); |
33 |
} |
34 |
|