This is a discussion on grep patch within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Hi, When using grep on more that one file, and if the number of lines of trailing context is ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, When using grep on more that one file, and if the number of lines of trailing context is greater that the number of remaining lines in the file after a matching line, grep will display the number of remaining lines of the next file. For instance, if you run grep to match a pattern which is on the last line of file1, with a context set to 2 lines (default) : $ grep -C "pattern" file1 file2 grep will also return the first 2 lines of file2, even if there's no matching pattern in it ! Best regards, Charles Longeau Index: usr.bin/grep/util.c ================================================== ================= RCS file: /cvs/src/usr.bin/grep/util.c,v retrieving revision 1.32 diff -u -p -r1.32 util.c --- usr.bin/grep/util.c 26 Sep 2006 15:55:17 -0000 1.32 +++ usr.bin/grep/util.c 15 Nov 2006 15:49:16 -0000 @@ -119,6 +119,7 @@ procfile(char *fn) ln.line_no = 0; ln.len = 0; linesqueued = 0; + tail = 0; ln.off = -1; if (Bflag > 0) |