gbranden pushed a commit to branch master
in repository groff.

commit 63984ee58b029a9dba61a099a0f7f348719e9c7d
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Sep 17 23:25:45 2025 -0500

    [troff]: Fix Savannah #67532 (diverted `trf`).
    
    * src/roff/troff/input.cpp (transparent_file): Test whether the current
      diversion is the top-level diversion.  If so, proceed as we have to
      date.  But if not, call `copy_file()` member function of the current
      diversion.
    
    Fixes <https://savannah.gnu.org/bugs/?67532>.  Problem appears to date
    back to groff's birth.
---
 ChangeLog                | 10 ++++++++++
 src/roff/troff/input.cpp | 31 ++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 07531b345..b5860f4dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-09-17  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (transparent_file): Test whether
+       the current diversion is the top-level diversion.  If so,
+       proceed as we have to date.  But if not, call `copy_file()`
+       member function of the current diversion.
+
+       Fixes <https://savannah.gnu.org/bugs/?67532>.  Problem appears
+       to date back to groff's birth.
+
 2025-09-17  G. Branden Robinson <[email protected]>
 
        [troff]: Regression-test Savannah #67532.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 1a347de82..969cb62c1 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8909,21 +8909,26 @@ void transparent_file()
     if (0 /* nullptr */ == fp)
       error("cannot open '%1': %2", filename, strerror(errno));
     else {
-      bool reading_beginning_of_input_line = true;
-      for (;;) {
-       int c = getc(fp);
-       if (c == EOF)
-         break;
-       if (is_invalid_input_char(c))
-         warning(WARN_INPUT, "invalid input character code %1", int(c));
-       else {
-         curdiv->transparent_output(c);
-         reading_beginning_of_input_line = c == '\n';
+      if (curdiv != topdiv)
+       curdiv->copy_file(filename);
+      else {
+       bool reading_beginning_of_input_line = true;
+       for (;;) {
+         int c = getc(fp);
+         if (c == EOF)
+           break;
+         if (is_invalid_input_char(c))
+           warning(WARN_INPUT, "invalid input character code %1",
+                   int(c));
+         else {
+           curdiv->transparent_output(c);
+           reading_beginning_of_input_line = c == '\n';
+         }
        }
+       if (!reading_beginning_of_input_line)
+         curdiv->transparent_output('\n');
+       fclose(fp);
       }
-      if (!reading_beginning_of_input_line)
-       curdiv->transparent_output('\n');
-      fclose(fp);
     }
   }
   tok.next();

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

Reply via email to