25 lines
764 B
Diff
25 lines
764 B
Diff
|
diff --git a/src/grep.c b/src/grep.c
|
||
|
--- a/src/grep.c
|
||
|
+++ b/src/grep.c
|
||
|
@@ -1415,13 +1415,13 @@ grep (int fd, struct stat const *st)
|
||
|
}
|
||
|
|
||
|
/* Detect whether leading context is adjacent to previous output. */
|
||
|
- if (lastout)
|
||
|
- {
|
||
|
- if (textbin == TEXTBIN_UNKNOWN)
|
||
|
- textbin = TEXTBIN_TEXT;
|
||
|
- if (beg != lastout)
|
||
|
- lastout = 0;
|
||
|
- }
|
||
|
+ if (beg != lastout)
|
||
|
+ lastout = 0;
|
||
|
+
|
||
|
+ /* If the file's textbin has not been determined yet, assume
|
||
|
+ it's text if has found any matched line already. */
|
||
|
+ if (textbin == TEXTBIN_UNKNOWN && nlines)
|
||
|
+ textbin = TEXTBIN_TEXT;
|
||
|
|
||
|
/* Handle some details and read more data to scan. */
|
||
|
save = residue + lim - beg;
|