Commit 748d5cab9a3d0d5d0edc28c8fd38430c684b1e55

Christian Weisgerber 2020-12-14T22:15:50

replace unprintable characters with '.' before passing them to curses Otherwise, ncurses will replace them with some printable representation whose width we can't predict, and wunctrl() fails to return the replacement for 0x80..0x9f. ok stsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/tog/tog.c b/tog/tog.c
index ca7f33b..8306375 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1190,10 +1190,13 @@ format_line(wchar_t **wlinep, int *widthp, const char *line, int wlimit,
 			if (wline[i] == L'\t') {
 				width = TABSIZE -
 				    ((cols + col_tab_align) % TABSIZE);
-				if (cols + width > wlimit)
-					break;
-				cols += width;
+			} else {
+				width = 1;
+				wline[i] = L'.';
 			}
+			if (cols + width > wlimit)
+				break;
+			cols += width;
 			i++;
 		} else {
 			err = got_error_from_errno("wcwidth");