gbranden pushed a commit to branch master
in repository groff.

commit 464323a43ff41662905cab39ba171daa73572767
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Apr 3 15:23:25 2026 -0500

    src/roff/troff/input.cpp: Refactor (2/2).
    
    * src/roff/troff/input.cpp (interpolate_macro_or_invoke_request): Drop
      early `return` when no invokable request or callable macro exists on
      control line.  Add assert(3)ion at end of function to enforce
      invariant: once we've processed a control line, either
      `can_accept_control_character` must be true or the token pending on
      the input stream must represent the end of input.
    
    Tested by temporarily deleting the `tok.next()` at the end of
    `system_request()` in "input.cpp" (recalling Savannah #68064).
    
    $ ../src/roff/groff/tests/sy-request-works.sh
    checking that 'sy' request works
    hello
    checking that parser returns to correct state after 'sy'
    
    ...FAILED
---
 ChangeLog                | 6 ++++++
 src/roff/troff/input.cpp | 7 ++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e4056b3a3..721895def 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
 
        * src/roff/troff/input.cpp: Promote `process_input_stack()`'s
        local `can_accept_control_character` from local to global.
+       (interpolate_macro_or_invoke_request): Drop early `return` when
+       no invokable request or callable macro exists on control line.
+       Add assert(3)ion at end of function to enforce invariant: once
+       we've processed a control line, either
+       `can_accept_control_character` must be true or the token pending
+       on the input stream must represent the end of input.
 
 2026-04-03  G. Branden Robinson <[email protected]>
 
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 982a2ad0e..a7c107dbb 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4672,10 +4672,11 @@ static void interpolate_macro_or_invoke_request(symbol 
nm,
   }
   if (p != 0 /* nullptr */)
     p->invoke(nm, do_not_want_next_token);
-  else {
+  else
     skip_line();
-    return;
-  }
+  assert(can_accept_control_character || tok.is_eof());
+  if (tok.is_newline())
+    can_accept_control_character = true;
 }
 
 static void decode_macro_call_arguments(macro_iterator *mi)

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

Reply via email to