comm: Stop skipping a line in the output

Because of how we output lines in the loop above, if we leave that loop
when the last line was not the same in both files, then either
`file1_line` or `file2_line` has not been output yet.
`process_remaining()` does not print that line either, since it
immediately reads a new line. So, output the previously-missing line
before we call that. :^)
This commit is contained in:
Sam Atkins 2022-09-13 16:15:53 +01:00 committed by Linus Groh
commit 8ed5403d8c
Notes: sideshowbarker 2024-07-18 00:54:03 +09:00

View file

@ -141,6 +141,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
// If the most recent line read was not a match, then the last line read from one of the files has not yet been output.
// So let's output it!
if (!read_file1 && !suppress_col1) {
++col1_count;
outln(col1_fmt, file1_line);
} else if (!read_file2 && !suppress_col2) {
++col2_count;
outln(col2_fmt, file2_line);
}
process_remaining(col1_fmt, file1, col1_count, !suppress_col1);
process_remaining(col2_fmt, file2, col2_count, !suppress_col2);