tweaks: condense a bit of copying code

master
Benno Schulenberg 2019-04-04 14:11:52 +02:00
parent 3f9d8011b9
commit 2a2fe7208a
1 changed files with 9 additions and 27 deletions

View File

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