* src/fmt.c (fmt): Pass errno to error() so that
the particular error is diagnosed.
* NEWS: Mention the improvement.
---
 NEWS      | 3 +++
 src/fmt.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 1ccc52426..78f15884a 100644
--- a/NEWS
+++ b/NEWS
@@ -81,6 +81,9 @@ GNU coreutils NEWS                                    -*- 
outline -*-
   'du' now processes directories with 10,000 or more entries up to 9 times
   faster on the Lustre file system.
 
+  'fmt' did now correctly diagnoses read errors.
+  Previously fmt generated a generic error for any read error.
+
   'pinky' will now exit immediately upon receiving a write error, which is
   significant when reading large plan or project files.
 
diff --git a/src/fmt.c b/src/fmt.c
index ae689ec28..8928a32b4 100644
--- a/src/fmt.c
+++ b/src/fmt.c
@@ -501,9 +501,9 @@ fmt (FILE *f, char const *file)
   if (0 <= err)
     {
       if (f == stdin)
-        error (0, err, _("read error"));
+        error (0, errno, _("read error"));
       else
-        error (0, err, _("error reading %s"), quoteaf (file));
+        error (0, errno, _("error reading %s"), quoteaf (file));
     }
   return err < 0;
 }
-- 
2.52.0


Reply via email to