Utilities: Fix grep match when reading from stdin

When reading from stdin, grep discards the last character,
even if that character is not \n.

This commit changes grep to no longer discard the last character from
a line.
This commit is contained in:
r-paiva 2021-04-29 16:07:17 +01:00 committed by Andreas Kling
parent eed0bcaf42
commit 68de9008e7
Notes: sideshowbarker 2024-07-18 17:40:22 +09:00

View file

@ -177,7 +177,7 @@ int main(int argc, char** argv)
ScopeGuard free_line = [line] { free(line); };
while ((nread = getline(&line, &line_len, stdin)) != -1) {
VERIFY(nread > 0);
StringView line_view(line, nread - 1);
StringView line_view(line, nread);
bool is_binary = line_view.contains(0);
if (is_binary && binary_mode == BinaryFileMode::Skip)