commit e5731fe198ef9c4a8d60991f70cf3c69daa3e7d4
parent 2bbb6cfeb56b1f4dde58f7c18ddfefee923649c8
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Sat, 25 Feb 2017 11:47:21 +0100
tweaks: reshuffle three statements, and shorten a comment
Diffstat:
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -1632,8 +1632,6 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
/* Find the last blank that does not overshoot the target column. */
while (*line != '\0' && column <= goal) {
- char_len = parse_mbchar(line, NULL, &column);
-
if (is_blank_mbchar(line) || (snap_at_nl && *line == '\n')) {
lastblank = index;
@@ -1641,6 +1639,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
break;
}
+ char_len = parse_mbchar(line, NULL, &column);
line += char_len;
index += char_len;
}
@@ -1656,17 +1655,15 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
return (index - char_len);
#endif
- /* If no blank was found within the goal width, try to find a
- * blank beyond it. */
+ /* If no blank was found within the goal width, seek one after it. */
if (lastblank < 0) {
while (*line != '\0') {
- char_len = parse_mbchar(line, NULL, NULL);
-
if (is_blank_mbchar(line))
lastblank = index;
else if (lastblank > 0)
return lastblank;
+ char_len = parse_mbchar(line, NULL, NULL);
line += char_len;
index += char_len;
}
@@ -1675,7 +1672,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
}
/* Move the pointer back to the last blank, and then step beyond it. */
- line += lastblank - index;
+ line = line - index + lastblank;
char_len = parse_mbchar(line, NULL, NULL);
line += char_len;