gbranden pushed a commit to branch master
in repository groff.

commit 9fb72aea10f51056a5cb5657f43cca70341e0018
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Dec 27 17:23:45 2023 -0600

    [troff]: Revise diags on opening, closing streams.
    
    * src/roff/troff/input.cpp (do_open, close_request): Do it.  Recast.
      Check `fclose()` for failure and report the system's error description
      upon failure.
---
 ChangeLog                |  8 ++++++++
 src/roff/troff/input.cpp | 12 ++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 182173085..c25497607 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-12-27  G. Branden Robinson <[email protected]>
+
+       [troff]: Revise diagnostics when opening and closing streams.
+
+       * src/roff/troff/input.cpp (do_open, close_request): Do it.
+       Recast.  Check `fclose()` for failure and report the system's
+       error description upon failure.
+
 2023-12-27  G. Branden Robinson <[email protected]>
 
        Support pic(1) pictures when formatting HTML and using
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index d1262f445..55cee7ede 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6960,7 +6960,7 @@ void do_open(int append)
       errno = 0;
       FILE *fp = fopen(filename.contents(), append ? "a" : "w");
       if (!fp) {
-       error("can't open '%1' for %2: %3",
+       error("unable to open file '%1' for %2: %3",
              filename.contents(),
              append ? "appending" : "writing",
              strerror(errno));
@@ -7001,9 +7001,13 @@ void close_request()
   if (!stream.is_null()) {
     FILE *fp = (FILE *)stream_dictionary.remove(stream);
     if (!fp)
-      error("no stream named '%1'", stream.contents());
-    else
-      fclose(fp);
+      error("cannot close nonexistent stream '%1'", stream.contents());
+    else {
+      int status = fclose(fp);
+       if (status != 0)
+         error("unable to close stream '%1': %2", stream.contents(),
+               strerror(errno));
+    }
   }
   skip_line();
 }

_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to