gbranden pushed a commit to branch master
in repository groff.

commit cc2713a064185634ae7aa4f973f08059625aa422
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Jul 14 02:36:02 2026 -0500

    src/roff/troff/input.cpp: Refactor.
    
    * src/roff/troff/input.cpp: Shift responsibility for positioning the
      input stream pointer prior to reading the next input line to request
      handlers more consistently.
    
      (open_file): Stop calling `tok.next()` before returning.
    
      (open_request, opena_request): Call `tok.next()` before returning.
    
      (read_rest_of_line_as_argument): Annotate future direction.
    
      (pipe_output, system_request)
      (unsafe_transparent_throughput_file_request): Update annotations.
---
 ChangeLog                | 13 +++++++++++++
 src/roff/troff/input.cpp | 20 +++++++++++++-------
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e70d77a2f..b1f046e75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,19 @@
        * doc/doc.am (doc/groff-pdf-features.pdf): Add
        "contrib/sboxes/sboxes.tmac" as prerequisite.
 
+2026-07-14  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp: Refactor; shift responsibility for
+       positioning the input stream pointer prior to reading the next
+       input line to request handlers more consistently.
+       (open_file): Stop calling `tok.next()` before returning.
+       (open_request, opena_request): Call `tok.next()` before
+       returning.
+       (read_rest_of_line_as_argument): Annotate future direction.
+       (pipe_output, system_request)
+       (unsafe_transparent_throughput_file_request): Update
+       annotations.
+
 2026-07-14  G. Branden Robinson <[email protected]>
 
        * tmac/s.tmac: Relocate initialization of new `cov*got-title`
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 087fe2176..f3657fc99 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8472,7 +8472,6 @@ static void open_file(bool appending)
                                 new grostream(filename, mode, &*fp));
       }
     }
-    tok.next();
   }
 }
 
@@ -8490,7 +8489,8 @@ static void open_request() // .open
   else
     open_file(false /* appending */);
   // No skip_line() here; open_file() calls
-  // read_rest_of_line_as_argument(), tok.next().
+  // read_rest_of_line_as_argument().
+  tok.next();
 }
 
 static void opena_request() // .opena
@@ -8507,7 +8507,8 @@ static void opena_request() // .opena
   else
     open_file(true /* appending */);
   // No skip_line() here; open_file() calls
-  // read_rest_of_line_as_argument(), tok.next().
+  // read_rest_of_line_as_argument().
+  tok.next();
 }
 
 static void close_stream(symbol &stream)
@@ -9535,8 +9536,12 @@ static void abort_request() // .ab
 // letting any immediately subsequent spaces populate the returned
 // string.
 //
-// The caller must subsequently call `tok.next()` to advance the input
-// stream pointer.
+// The caller must subsequently call `tok.next()`, _not_ `skip_line()`,
+// to advance the input stream pointer.
+//
+// TODO: Synthesize a newline token and push it onto the input stream so
+// that the foregoing becomes unnecessary, and request handlers can
+// uniformly use `skip_line()`.
 //
 // The caller has responsibility for `delete`ing the returned buffer.
 char *read_rest_of_line_as_argument()
@@ -9612,6 +9617,7 @@ static void pipe_output() // .pi
   else
     pipe_command = pc;
   delete[] pc;
+  // No skip_line() here; we called read_rest_of_line_as_argument().
   tok.next();
 }
 
@@ -9639,7 +9645,7 @@ static void system_request() // .sy
   else
     system_status = system(command);
   delete[] command;
-  // XXX: Why not `skip_line()`?
+  // No skip_line() here; we called read_rest_of_line_as_argument().
   tok.next();
 }
 
@@ -9666,7 +9672,7 @@ static void unsafe_transparent_throughput_file_request() 
// .cf
   if (filename != 0 /* nullptr */)
     curdiv->copy_file(filename);
   // TODO: Add `filename` to file name set.
-  // XXX: Why not `skip_line()`?
+  // No skip_line() here; we called read_rest_of_line_as_argument().
   tok.next();
 }
 

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

Reply via email to