commit 3a65c0d1929ae8f7c3465c18696c7a6cb7548cd5
parent e1c011c9a10b5132a9e931a0e7df90b265b685a4
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 30 May 2019 19:46:08 +0200
feedback: when the last line is empty, don't include it in the count
Now M-D will report 0 lines instead of 1 line for an empty buffer, and
will match the output of 'wc --lines' as long the file is a POSIX file.
This fixes https://savannah.gnu.org/bugs/?56054.
Bug existed since before version 2.1.10.
Diffstat:
1 file changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -3061,6 +3061,7 @@ void do_wordlinechar_count(void)
* do, but get the latter in multibyte characters. */
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
@@ -3069,6 +3070,7 @@ void do_wordlinechar_count(void)
openfile->mark = was_mark;
} else {
lines = openfile->filebot->lineno;
+ lines -= (openfile->filebot->data[0] == '\0') ? 1 : 0;
chars = openfile->totsize;
}