bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] grep: suppress read errors if -s


From: Paul Eggert
Subject: [PATCH 2/4] grep: suppress read errors if -s
Date: Fri, 20 Jan 2012 23:07:04 -0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0

* src/main.c (reset, grep, grepfile): Do not report an input error
if -s is given.
---
 src/main.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main.c b/src/main.c
index 62ce7e3..893f025 100644
--- a/src/main.c
+++ b/src/main.c
@@ -502,7 +502,7 @@ reset (int fd, char const *file, struct stats *stats)
           bufoffset = lseek (fd, 0, SEEK_CUR);
           if (bufoffset < 0)
             {
-              error (0, errno, _("lseek failed"));
+              suppressible_error (_("lseek failed"), errno);
               return 0;
             }
         }
@@ -1109,7 +1109,7 @@ grep (int fd, char const *file, struct stats *stats)
       /* Close fd now, so that we don't open a lot of file descriptors
          when we recurse deeply.  */
       if (close (fd) != 0)
-        error (0, errno, "%s", file);
+        suppressible_error (file, errno);
       return grepdir (file, stats) - 2;
     }
 
@@ -1289,7 +1289,8 @@ grepfile (char const *file, struct stats *stats)
       && S_ISREG (out_stat.st_mode) && out_stat.st_ino
       && SAME_INODE (stats->stat, out_stat))
     {
-      error (0, 0, _("input file %s is also the output"), quote (filename));
+      if (! suppress_errors)
+        error (0, 0, _("input file %s is also the output"), quote (filename));
       errseen = 1;
       if (file)
         close (desc);
@@ -1344,13 +1345,13 @@ grepfile (char const *file, struct stats *stats)
           if (required_offset != bufoffset
               && lseek (desc, required_offset, SEEK_SET) < 0
               && S_ISREG (stats->stat.st_mode))
-            error (0, errno, "%s", filename);
+            suppressible_error (filename, errno);
         }
       else
         while (close (desc) != 0)
           if (errno != EINTR)
             {
-              error (0, errno, "%s", file);
+              suppressible_error (file, errno);
               break;
             }
     }
-- 
1.7.6.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]