Thu Apr 18 16:05:24 2024 UTC (21d)
Pull up following revision(s) (requested by riastradh in ticket #1832):

	external/gpl2/grep/dist/src/grep.c: revision 1.3

PR/56584: Andreas Gustafsson: Skip FIFO's when -D


(martin)
diff -r1.2 -r1.2.18.1 src/external/gpl2/grep/dist/src/grep.c

cvs diff -r1.2 -r1.2.18.1 src/external/gpl2/grep/dist/src/grep.c (expand / switch to unified diff)

--- src/external/gpl2/grep/dist/src/grep.c 2016/01/10 22:16:40 1.2
+++ src/external/gpl2/grep/dist/src/grep.c 2024/04/18 16:05:24 1.2.18.1
@@ -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.18.1 2024/04/18 16:05: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 }