From 472401a51e4f33bdf201ff465866bb4afa95d422 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 31 Oct 2021 16:24:11 +0100 Subject: [PATCH] Revert "wc: Count last line even if it doesn't end in newline" This reverts commit f356c4ab915da052d17b7e5d2ffb5d1a695c95f0. According to Dr. POSIX, `wc -l` should print the number of *newlines* in the input. --- Userland/Utilities/wc.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Userland/Utilities/wc.cpp b/Userland/Utilities/wc.cpp index 1e9d3b54a0..dc36e768c5 100644 --- a/Userland/Utilities/wc.cpp +++ b/Userland/Utilities/wc.cpp @@ -55,9 +55,7 @@ static Count get_count(const String& file_specifier) } bool start_a_new_word = true; - int last_ch = EOF; for (int ch = fgetc(file_pointer); ch != EOF; ch = fgetc(file_pointer)) { - last_ch = ch; count.bytes++; if (isspace(ch)) { start_a_new_word = true; @@ -68,8 +66,6 @@ static Count get_count(const String& file_specifier) count.words++; } } - if (last_ch != '\n') - count.lines++; if (file_pointer != stdin) fclose(file_pointer);