gbranden pushed a commit to branch master
in repository groff.
commit 41ff764bb1739ded9bafaa4d96fe49c6b1c0f8a0
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Sep 13 06:14:38 2024 -0500
Clean up streams on formatter exit.
(close_all_streams): New function iterates `stream_dictionary` and
closes each stream.
(exit_troff): Call `close_all_streams()`.
---
src/roff/troff/input.cpp | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 54f7dd61a..d13c89d5f 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2836,9 +2836,12 @@ static symbol do_get_long_name(bool required, char
end_char)
}
}
+static void close_all_streams();
+
void exit_troff()
{
is_exit_underway = true;
+ close_all_streams();
topdiv->set_last_page();
if (!end_of_input_macro_name.is_null()) {
spring_trap(end_of_input_macro_name);
@@ -7307,6 +7310,23 @@ static void close_stream(symbol &stream)
stream_dictionary.remove(stream);
}
+// Call this from exit_troff().
+static void close_all_streams()
+{
+ object_dictionary_iterator iter(stream_dictionary);
+ FILE *filestream;
+ symbol stream;
+ while (iter.get(&stream, (object **)&filestream)) {
+ assert(!stream.is_null());
+ if (stream != 0 /* nullptr */) {
+ warning(WARN_FILE, "stream '%1' still open; closing",
+ stream.contents());
+ close_stream(stream);
+ }
+ }
+ skip_line();
+}
+
static void close_request() // .close
{
if (!has_arg(true /* peek */)) {
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit