| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: grep.c,v 1.2 2016/01/10 22:16:40 christos Exp $ */ | | 1 | /* $NetBSD: grep.c,v 1.2.8.1 2024/04/18 16:06:24 martin Exp $ */ |
2 | | | 2 | |
3 | /* grep.c - main driver file for grep. | | 3 | /* grep.c - main driver file for grep. |
4 | Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc. | | 4 | Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc. |
5 | | | 5 | |
6 | This program is free software; you can redistribute it and/or modify | | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2, or (at your option) | | 8 | the Free Software Foundation; either version 2, or (at your option) |
9 | any later version. | | 9 | any later version. |
10 | | | 10 | |
11 | This program is distributed in the hope that it will be useful, | | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | | 14 | GNU General Public License for more details. |
| @@ -261,31 +261,35 @@ reset (int fd, char const *file, struct | | | @@ -261,31 +261,35 @@ reset (int fd, char const *file, struct |
261 | } | | 261 | } |
262 | | | 262 | |
263 | bufbeg = buflim = ALIGN_TO (buffer + 1, pagesize); | | 263 | bufbeg = buflim = ALIGN_TO (buffer + 1, pagesize); |
264 | bufbeg[-1] = eolbyte; | | 264 | bufbeg[-1] = eolbyte; |
265 | bufdesc = fd; | | 265 | bufdesc = fd; |
266 | | | 266 | |
267 | if (fstat (fd, &stats->stat) != 0) | | 267 | if (fstat (fd, &stats->stat) != 0) |
268 | { | | 268 | { |
269 | error (0, errno, "fstat"); | | 269 | error (0, errno, "fstat"); |
270 | return 0; | | 270 | return 0; |
271 | } | | 271 | } |
272 | if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) | | 272 | if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode)) |
273 | return 0; | | 273 | return 0; |
274 | #ifndef DJGPP | | 274 | if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) |
275 | if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode))) | | 275 | || S_ISBLK(stats->stat.st_mode) |
276 | #else | | 276 | #ifdef S_ISSOCK |
277 | if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode))) | | 277 | || S_ISSOCK(stats->stat.st_mode) |
| | | 278 | #endif |
| | | 279 | #ifdef S_ISFIFO |
| | | 280 | || S_ISFIFO(stats->stat.st_mode) |
278 | #endif | | 281 | #endif |
| | | 282 | )) |
279 | return 0; | | 283 | return 0; |
280 | if (S_ISREG (stats->stat.st_mode)) | | 284 | if (S_ISREG (stats->stat.st_mode)) |
281 | { | | 285 | { |
282 | if (file) | | 286 | if (file) |
283 | bufoffset = 0; | | 287 | bufoffset = 0; |
284 | else | | 288 | else |
285 | { | | 289 | { |
286 | bufoffset = lseek (fd, 0, SEEK_CUR); | | 290 | bufoffset = lseek (fd, 0, SEEK_CUR); |
287 | if (bufoffset < 0) | | 291 | if (bufoffset < 0) |
288 | { | | 292 | { |
289 | error (0, errno, "lseek"); | | 293 | error (0, errno, "lseek"); |
290 | return 0; | | 294 | return 0; |
291 | } | | 295 | } |