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').
master
Benno Schulenberg 2017-02-25 11:17:12 +01:00
parent 1623bc7779
commit 2bbb6cfeb5
1 changed files with 6 additions and 5 deletions

View File

@ -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)) {
char_len = parse_mbchar(line, NULL, NULL);
line += char_len;
lastblank += char_len;
char_len = parse_mbchar(line, NULL, NULL);
line += char_len;
}
return lastblank;