commit 2bbb6cfeb56b1f4dde58f7c18ddfefee923649c8
parent 1623bc77795cafe01d6f0766a3923b87dbe89d3e
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 25 Feb 2017 11:17:12 +0100
wrapping: add the correct char length when skipping consecutive blanks
In this last loop of break_line(), the pointer 'line' is one step ahead
of the index 'lastblank'. So the loop should first add the length of
the preceding character to 'lastblank' before determining the length
of the current character (and using this to advance 'line').
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -1674,15 +1674,16 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
return -1;
}
+ /* Move the pointer back to the last blank, and then step beyond it. */
line += lastblank - index;
- line += parse_mbchar(line, NULL, NULL);
+ char_len = parse_mbchar(line, NULL, NULL);
+ line += char_len;
- /* Skip any consecutive blanks after the last found blank. */
+ /* Skip any consecutive blanks after the last blank. */
while (*line != '\0' && is_blank_mbchar(line)) {
+ lastblank += char_len;
char_len = parse_mbchar(line, NULL, NULL);
-
line += char_len;
- lastblank += char_len;
}
return lastblank;