SHA256
3
0
forked from pool/grep
grep/skip-devices.diff

54 lines
1.8 KiB
Diff

2004-11-20 Benno Schulenberg <benno@nietvergeten.nl> (tiny change)
* src/grep.c (reset): Move the stat check ...
(grepfile): ... here, and also check for a fifo.
Index: src/grep.c
===================================================================
RCS file: /sources/grep/grep/src/grep.c,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -a -p -u -p -a -r1.83 -r1.84
--- src/grep.c 20 Nov 2004 16:15:57 -0000 1.83
+++ src/grep.c 20 Nov 2004 16:20:38 -0000 1.84
@@ -255,19 +255,6 @@ reset (int fd, char const *file, struct
bufbeg[-1] = eolbyte;
bufdesc = fd;
- if (fstat (fd, &stats->stat) != 0)
- {
- error (0, errno, "fstat");
- return 0;
- }
- if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
- return 0;
-#ifndef DJGPP
- if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode)))
-#else
- if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
-#endif
- return 0;
if (S_ISREG (stats->stat.st_mode))
{
if (file)
@@ -928,6 +915,19 @@ grepfile (char const *file, struct stats
}
else
{
+ if (stat (file, &stats->stat) != 0)
+ {
+ suppressible_error (file, errno);
+ return 1;
+ }
+ if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
+ return 1;
+#ifndef DJGPP
+ if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode)))
+#else
+ if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
+#endif
+ return 1;
while ((desc = open (file, O_RDONLY)) < 0 && errno == EINTR)
continue;