commit e98847200e93b7914630f0aeeb778b5ed5e38212
parent a77b21388abd869b932d771b2bcfedbdbc3f4107
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 31 May 2019 17:22:47 +0200
tweaks: reshuffle some lines, to reduce duplication
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -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;
}