nano

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

commit 2a2fe7208a4d5fa67fffe821b2046f42f808554e
parent 3f9d8011b90139eeedde5e2b7d86cf1743bab06b
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu,  4 Apr 2019 14:11:52 +0200

tweaks: condense a bit of copying code

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

diff --git a/src/text.c b/src/text.c @@ -1681,15 +1681,11 @@ void squeeze(linestruct *line, size_t skip) /* If this character is blank, change it to a space, * and pass over all blanks after it. */ if (is_blank_mbchar(from)) { - charlen = parse_mbchar(from, NULL, NULL); - - *to = ' '; - to++; - from += charlen; + from += parse_mbchar(from, NULL, NULL); + *(to++) = ' '; while (*from != '\0' && is_blank_mbchar(from)) { charlen = parse_mbchar(from, NULL, NULL); - from += charlen; shrunk += charlen; } @@ -1700,9 +1696,7 @@ void squeeze(linestruct *line, size_t skip) charlen = parse_mbchar(from, NULL, NULL); while (charlen > 0) { - *to = *from; - to++; - from++; + *(to++) = *(from++); charlen--; } @@ -1710,32 +1704,22 @@ void squeeze(linestruct *line, size_t skip) charlen = parse_mbchar(from, NULL, NULL); while (charlen > 0) { - *to = *from; - to++; - from++; + *(to++) = *(from++); charlen--; } } if (*from != '\0' && is_blank_mbchar(from)) { - charlen = parse_mbchar(from, NULL, NULL); - - *to = ' '; - to++; - from += charlen; + from += parse_mbchar(from, NULL, NULL); + *(to++) = ' '; } - if (*from != '\0' && is_blank_mbchar(from)) { - charlen = parse_mbchar(from, NULL, NULL); - - *to = ' '; - to++; - from += charlen; + from += parse_mbchar(from, NULL, NULL); + *(to++) = ' '; } while (*from != '\0' && is_blank_mbchar(from)) { charlen = parse_mbchar(from, NULL, NULL); - from += charlen; shrunk += charlen; } @@ -1744,9 +1728,7 @@ void squeeze(linestruct *line, size_t skip) charlen = parse_mbchar(from, NULL, NULL); while (charlen > 0) { - *to = *from; - to++; - from++; + *(to++) = *(from++); charlen--; } }