summary refs log tree commit diff
path: root/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/buffer.c b/buffer.c
index 740e598..15d89f8 100644
--- a/buffer.c
+++ b/buffer.c
@@ -160,11 +160,18 @@ static int flow(struct Lines *hard, int cols, const struct Line *soft) {
 			wrapStyle = style;
 		}
 
-		n = mbtowc(&wc, wrap, strlen(wrap));
-		if (n < 0) {
-			n = 1;
-		} else if (!iswspace(wc)) {
-			n = 0;
+		n = 0;
+		len = strlen(wrap);
+		for (int m; wrap[n] && (m = mbtowc(&wc, &wrap[n], len - n)); n += m) {
+			if (m < 0) {
+				m = 1;
+			} else if (!iswspace(wc)) {
+				break;
+			}
+		}
+		if (!wrap[n]) {
+			*wrap = '\0';
+			break;
 		}
 
 		flowed++;
an>Disable terminal flow controlJune McEnroe 2019-02-22Bind up and down arrows to scrollJune McEnroe 2019-02-22Remove topic TODOJune McEnroe 2019-02-22Add /znc commandJune McEnroe 2019-02-22Update status line after scrolling and term eventsJune McEnroe 2019-02-22Reorganize input.cJune McEnroe 2019-02-22Fix name of <raw> window in man pageJune McEnroe 2019-02-22Rename global tags with angle bracketsJune McEnroe 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe 2019-02-21Replace "view" with "window"June McEnroe 2019-02-21Remove ROT13June McEnroe 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe