Commit 2bbb6cfe authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

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').
No related merge requests found
Showing with 5 additions and 4 deletions
+5 -4
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment