From 2a2fe7208a4d5fa67fffe821b2046f42f808554e Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 4 Apr 2019 14:11:52 +0200 Subject: [PATCH] tweaks: condense a bit of copying code --- src/text.c | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/src/text.c b/src/text.c index 5186c25b..1fca36c7 100644 --- 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--; } }