When using the match count flag (-m), grep was not printing the
context after the match if the -A or -C flags were provided.
This changes the logic to continue printing lines after hitting the
match count.
ok op@, millert@
-/* $OpenBSD: util.c,v 1.64 2021/12/28 16:27:53 otto Exp $ */
+/* $OpenBSD: util.c,v 1.65 2022/05/30 16:07:28 dv Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
overflow = 1;
else
c += t;
- if (mflag && mcount <= 0)
+ if (mflag && mcount <= 0 && tail <= 0)
break;
}
if (Bflag > 0)
c = 1;
goto print;
}
+ if (mflag && mcount <= 0)
+ goto print;
for (i = 0; i < patterns; i++) {
offset = 0;