mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
Revert "wc: Count last line even if it doesn't end in newline"
This reverts commit f356c4ab91
.
According to Dr. POSIX, `wc -l` should print the number of *newlines*
in the input.
This commit is contained in:
parent
aff2b42f82
commit
472401a51e
Notes:
sideshowbarker
2024-07-18 01:39:54 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/472401a51e4
1 changed files with 0 additions and 4 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue