Blame grep-2.22-Pc-consistent-results.patch

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