gbranden pushed a commit to branch master
in repository groff.

commit 0955b091c86ae5ae2a71abec0c86e48c320b7577
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu May 28 14:43:05 2026 -0500

    src/roff/troff/input.cpp: Refactor `has_arg()`.
    
    * src/roff/troff/input.cpp (has_arg): Revise semantics.  Function now
      returns `false` if the current token is anything but a space.
---
 ChangeLog                |  6 ++++++
 src/roff/troff/input.cpp | 17 +++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 35910d79b..41068d938 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-05-28  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (has_arg): Revise semantics.
+       Function now returns `false` if the current token is anything
+       but a space.
+
 2026-05-28  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/div.cpp (set_page_number_request): Refactor--
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 5a99a0a1b..57a367f69 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2182,19 +2182,24 @@ void token::diagnose_non_character()
          " ignoring", description());
 }
 
-// Indicate whether an argument lies ahead on the current line in the
-// input stream, skipping over spaces.  This function is therefore not
-// appropriate for use when handling requests or escape sequences that
-// don't use space to separate their arguments, as with `.tr aAbB` or
-// `\o'^e'`.
+// Indicate whether an argument lies ahead, _after at least one space_,
+// on the current line in the input stream, skipping over spaces.  This
+// function is therefore not appropriate for use when handling requests
+// or escape sequences that don't use space to separate their arguments,
+// as with `.rchar a\[foobar]b` or `\o'^e'`.
 //
 // Specify `peeking` if request reads the next argument in copy mode,
 // or otherwise must interpret it specially, as when reading a
 // conditional expression (`if`, `ie`, `while`), or expecting a
 // delimited argument (`tl`).
+//
+// Note: Do not call this function repeatedly without doing something to
+// advance the input stream cursor (such as calling `read_identifier()`)
+// beforehand.  If the current token is not a space, an argument does
+// not "lie ahead", and the request handler's logic may fail.
 bool has_arg(bool peeking)
 {
-  if (tok.is_newline() || tok.is_eof())
+  if (!tok.is_space())
     return false;
   if (peeking) {
     int c;

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

Reply via email to