tweaks: reshuffle some lines, to reduce duplication

master
Benno Schulenberg 2019-05-31 17:22:47 +02:00
parent a77b21388a
commit e98847200e
1 changed files with 5 additions and 6 deletions

View File

@ -3058,11 +3058,12 @@ void do_wordlinechar_count(void)
words++;
}
/* Get the total line and character counts, as "wc -l" and "wc -c"
* do, but get the latter in multibyte characters. */
/* Get the number of lines, similar to what "wc -l" gives. */
lines = openfile->filebot->lineno - openfile->filetop->lineno +
((openfile->filebot->data[0] == '\0') ? 0 : 1);
/* Get the number of multibyte characters, similar to "wc -c". */
if (was_mark) {
lines = openfile->filebot->lineno - openfile->filetop->lineno + 1;
lines -= (openfile->filebot->data[0] == '\0') ? 1 : 0;
chars = get_totsize(openfile->filetop, openfile->filebot);
/* Unpartition the buffer so that it contains all the text
@ -3070,8 +3071,6 @@ void do_wordlinechar_count(void)
unpartition_buffer(&filepart);
openfile->mark = was_mark;
} else {
lines = openfile->filebot->lineno;
lines -= (openfile->filebot->data[0] == '\0') ? 1 : 0;
chars = openfile->totsize;
}