nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit f3b030c8e535c93c9a23cd09cb2b8bde43ece187
parent 6b8b7c9d5572d60df8d630e30d31de6084495ef0
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 12 Mar 2020 16:57:24 +0100

tweaks: condense a fragment of code

Leave the skipping of subsequent blanks to the succeeding code.

Diffstat:
Msrc/text.c | 15++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -1394,17 +1394,14 @@ ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl) #endif /* If no blank was found within the goal width, seek one after it. */ - if (lastblank == NULL) { - while (*pointer != '\0') { - if (is_blank_char(pointer)) - lastblank = pointer; - else if (lastblank) - return (lastblank - textstart); + while (lastblank == NULL) { + if (*pointer == '\0') + return -1; + if (is_blank_char(pointer)) + lastblank = pointer; + else pointer += char_length(pointer); - } - - return -1; } /* Move the pointer back to the last blank, and then step beyond it. */