gbranden pushed a commit to branch master
in repository groff.

commit 994fcce7752e98e42e8465d874eeff2613cc1415
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun May 24 22:59:16 2026 -0500

    [troff]: Refactor `hcode` request handler.
    
    * src/roff/troff/input.cpp (set_hyphenation_codes): Refactor in
      preparation for firming-up of the semantics and logic of request
      arguments to constitute space-separated lexical tokens, as our
      documentation defines "argument".  Call `token::skip_spaces()` when
      "pumping" the input stream and govern the input-reading loop using
      `token::is_newline()` and `token::is_eof()` instead of `has_arg()`.
---
 ChangeLog                | 10 ++++++++++
 src/roff/troff/input.cpp |  9 +++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8021febe8..79b718807 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-05-24  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (set_hyphenation_codes):
+       Refactor in preparation for firming-up of the semantics and
+       logic of request arguments to constitute space-separated lexical
+       tokens, as our documentation defines "argument".  Call
+       `token::skip_spaces()` when "pumping" the input stream and
+       govern the input-reading loop using `token::is_newline()` and
+       `token::is_eof()` instead of `has_arg()`.
+
 2026-05-24  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (set_character_flags_request):
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 75b3badab..5a99a0a1b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8886,7 +8886,8 @@ static void set_hyphenation_codes() // .hcode
     skip_line();
     return;
   }
-  while (has_arg()) {
+  tok.skip_spaces();
+  do {
     unsigned char cdst = tok.ch();
     if (!tok.is_any_character()) {
       error("cannot apply a hyphenation code to %1", tok.description());
@@ -8904,8 +8905,8 @@ static void set_hyphenation_codes() // .hcode
        break;
       }
     }
-    tok.next();
-    if (!has_arg()) {
+    tok.skip_spaces();
+    if (tok.is_newline() || tok.is_eof()) {
       error("hyphenation codes must be specified in pairs");
       break;
     }
@@ -8945,7 +8946,7 @@ static void set_hyphenation_codes() // .hcode
       cidst->get_translation()->set_hyphenation_code(new_code);
     tok.next();
     tok.skip_spaces();
-  }
+  } while ((!tok.is_newline()) && (!tok.is_eof()));
   skip_line();
 }
 

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

Reply via email to