summary refs log tree commit diff
diff options
context:
space:
mode:
-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++;
href='/torus/commit/torus.h?h=ansi&id=6f8a935ad423b4d44fc7c63804c14858c12ba137&follow=1'>Track tile access countsJune McEnroe 2017-07-31Adjust move speed in clientJune McEnroe 2017-07-31Handle large movesJune McEnroe 2017-07-30Optimize builds for chrootJune McEnroe 2017-07-30Persist bright across color changesJune McEnroe 2017-07-30Add index.htmlJune McEnroe 2017-07-30Add snapshot.shJune McEnroe 2017-07-30Fix termcap patch for background colorsJune McEnroe 2017-07-30Update helpJune McEnroe 2017-07-30Fix help to track colorJune McEnroe 2017-07-30Support background colorsJune McEnroe 2017-07-30Track color only client-sideJune McEnroe 2017-07-30Add ostensible support for background colorsJune McEnroe 2017-07-30Add tile create and access timestampsJune McEnroe 2017-07-30Assert stable struct Tile field offsetsJune McEnroe 2017-07-30Add chroot.shJune McEnroe 2017-07-30Add ` commandJune McEnroe 2017-07-30Add sshd_configJune McEnroe 2017-07-30Add termcap patchJune McEnroe