about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-01-26 00:25:13 +0000
committerJames Booth <boothj5@gmail.com>2016-01-26 00:25:13 +0000
commit0501e49623f68aa39508e4e622924c1dd8147588 (patch)
tree3d2c489ee4b14c105b9077965afdefeaddfbe611
parent38dfdb9d844d7b63322b42372b95562f353453ef (diff)
downloadprofani-tty-0501e49623f68aa39508e4e622924c1dd8147588.tar.gz
Fix handling of unknown characters with word wrap
-rw-r--r--src/ui/window.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 8af57cfd..33ea86e0 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -1195,7 +1195,11 @@ _win_print_wrapped(WINDOW *win, const char *const message, size_t indent, int pa
             wordi = 0;
             int wordlen = 0;
             while (*curr_ch != ' ' && *curr_ch != '\n' && *curr_ch != '\0') {
-                size_t ch_len = mbrlen(curr_ch, 4, NULL);
+                size_t ch_len = mbrlen(curr_ch, MB_CUR_MAX, NULL);
+                if ((ch_len == (size_t)-2) || (ch_len == (size_t)-1)) {
+                    curr_ch++;
+                    continue;
+                }
                 int offset = 0;
                 while (offset < ch_len) {
                     word[wordi++] = curr_ch[offset++];