about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2019-03-21 15:59:42 +0100
committerLeah Neukirchen <leah@vuxu.org>2019-03-21 15:59:42 +0100
commit0d73424edf1476696270c7bbb2f79764c05a3e5e (patch)
tree0fce72391e361bafeec837921d8d0d56307450ba
parentb052723eacb71839f86ae6b6d3b862ab781485c4 (diff)
downloadmblaze-0d73424edf1476696270c7bbb2f79764c05a3e5e.tar.gz
mblaze-0d73424edf1476696270c7bbb2f79764c05a3e5e.tar.xz
mblaze-0d73424edf1476696270c7bbb2f79764c05a3e5e.zip
mscan: u8putstr: assume wcwidth of -1 means actually 2 (probably emojis)
-rw-r--r--mscan.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mscan.c b/mscan.c
index ae4fe35..c9a00a4 100644
--- a/mscan.c
+++ b/mscan.c
@@ -56,7 +56,10 @@ u8putstr(FILE *out, char *s, ssize_t l, int pad)
 				l--;
 				fprintf(out, "%lc", (wint_t)replacement);
 			} else {
-				l -= wcwidth((wchar_t)c);
+				int w = wcwidth((wchar_t)c);
+				if (w < 0)
+					w = 2;   /* assume worst width */
+				l -= w;
 				if (l >= 0)
 					fwrite(s, 1, r, out);
 			}