gbranden pushed a commit to branch master
in repository groff.

commit a36a2dfa8e580513595cb7df84c518067fe239dd
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Oct 17 17:41:03 2026 -0500

    [troff]: Add `skip_rest_of_argument()`.
    
    * src/roff/troff/input.cpp (skip_rest_of_argument): New function pumps
      input stream until a newline, space, or EOF token is reached.
    
    * src/roff/troff/token.h: Declare for external visibility.
    
    No call sites yet.
---
 ChangeLog                |  9 +++++++++
 src/roff/troff/input.cpp | 11 +++++++++++
 src/roff/troff/token.h   |  1 +
 3 files changed, 21 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 10551dc45..4ece2cdfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-10-17  G. Branden Robinson <[email protected]>
+
+       [troff]: Add `skip_rest_of_argument()`.
+
+       * src/roff/troff/input.cpp (skip_rest_of_argument): New function
+       pumps input stream until a newline, space, or EOF token is
+       reached.
+       * src/roff/troff/token.h: Declare for external visibility.
+
 2026-10-17  G. Branden Robinson <[email protected]>
 
        [groff]: Unit-test `rr` request.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index a3f5c4c2c..3b883d6d7 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3252,6 +3252,17 @@ const char *token::description()
   }
 }
 
+// Requests like `rm` and `rr` need to scan past the rest of an invalid
+// identifier to get to the next one, which may be valid.
+void skip_rest_of_argument()
+{
+  while ((!tok.is_newline()) && (!tok.is_space()))
+    if (tok.is_eof())
+      return;
+    else
+      tok.next();
+}
+
 void skip_line()
 {
   while (!tok.is_newline())
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index 843e3d64d..f45f2b012 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -130,6 +130,7 @@ public:
 extern token tok;              // the current token
 
 extern bool has_arg(bool /* peeking */ = false);
+extern void skip_rest_of_argument();
 extern void skip_line();
 extern symbol read_identifier(bool /* want_diagnostic */ = false);
 extern symbol read_long_identifier(bool /* want_diagnostic */ = false);

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

Reply via email to