gbranden pushed a commit to branch master
in repository groff.

commit 9dc26fa27a9dfefd26c7b7ea499c7c7c64683e66
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Nov 19 21:51:34 2025 -0600

    [troff]: Trivially refactor.
    
    Rename `skip()` member function of `token` class to `skip_spaces()` so
    that it is obvious at all of its (many) call sites what, exactly, it's
    doing with the input stream.
    
    * src/roff/troff/token.h (class token): Rename declaration.
    * src/roff/troff/input.cpp (token::skip): Rename definition from this...
      (token::skip_spaces): ...to this.
    
    * src/roff/troff/div.cpp (do_divert):
    * src/roff/troff/env.cpp (margin_character, environment_copy):
    * src/roff/troff/input.cpp (has_arg, read_identifier)
      (do_get_long_name, define_character, print_character_request)
      (do_register, nop_request, is_conditional_expression_true)
      (do_translate, set_hyphenation_codes)
      (hyphenation_patterns_file_code, define_class_request)
      (read_character, read_drawing_command):
    * src/roff/troff/node.cpp (read_font_identifier):
    * src/roff/troff/number.cpp (is_valid_expression, is_valid_term):
    * src/roff/troff/reg.cpp (assign_register_format_request): Update call
      sites.
---
 ChangeLog                 | 25 +++++++++++++++++++++++++
 src/roff/troff/div.cpp    |  2 +-
 src/roff/troff/env.cpp    |  4 ++--
 src/roff/troff/input.cpp  | 36 ++++++++++++++++++------------------
 src/roff/troff/node.cpp   |  2 +-
 src/roff/troff/number.cpp |  4 ++--
 src/roff/troff/reg.cpp    |  2 +-
 src/roff/troff/token.h    |  2 +-
 8 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1763d63dd..6f0c27f9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2025-11-19  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor.  Rename `skip()` member function of
+       `token` class to `skip_spaces()` so that it is obvious at all of
+       its (many) call sites what, exactly, it's doing with the input
+       stream.
+
+       * src/roff/troff/token.h (class token): Rename declaration.
+       * src/roff/troff/input.cpp (token::skip): Rename definition from
+       this...
+       (token::skip_spaces): ...to this.
+       * src/roff/troff/div.cpp (do_divert):
+       * src/roff/troff/env.cpp (margin_character, environment_copy):
+       * src/roff/troff/input.cpp (has_arg, read_identifier)
+       (do_get_long_name, define_character, print_character_request)
+       (do_register, nop_request, is_conditional_expression_true)
+       (do_translate, set_hyphenation_codes)
+       (hyphenation_patterns_file_code, define_class_request)
+       (read_character, read_drawing_command):
+       * src/roff/troff/node.cpp (read_font_identifier):
+       * src/roff/troff/number.cpp (is_valid_expression)
+       (is_valid_term):
+       * src/roff/troff/reg.cpp (assign_register_format_request):
+       Update call sites.
+
 2025-11-19  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/env.cpp (margin_character):
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 3d8abc179..fcd657b68 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -100,7 +100,7 @@ diversion *curdiv;
 
 void do_divert(bool appending, bool boxing)
 {
-  tok.skip();
+  tok.skip_spaces();
   symbol nm = read_identifier();
   if (nm.is_null()) {
     // Why the asymmetric diagnostic severity?  See Savannah #67139.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 5198e0123..663fc1b2a 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1673,7 +1673,7 @@ void underline()
 
 void margin_character()
 {
-  tok.skip();
+  tok.skip_spaces();
   charinfo *ci = tok.get_charinfo();
   if (ci != 0 /* nullptr */) {
     // Call tok.next() only after making the node so that
@@ -3772,7 +3772,7 @@ void environment_copy()
     return;
   }
   environment *e = 0 /* nullptr */;
-  tok.skip();
+  tok.skip_spaces();
   symbol nm = get_long_name();
   assert(nm != 0 /* nullptr */);
   e = static_cast<environment *>(env_dictionary.lookup(nm));
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index eca551564..b6fbb1ee4 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2009,7 +2009,7 @@ void token::operator=(const token &t)
   type = t.type;
 }
 
-void token::skip()
+void token::skip_spaces()
 {
   while (is_space())
     next();
@@ -2041,7 +2041,7 @@ bool has_arg(bool want_peek)
     return !(('\n' == c) || (EOF == c));
   }
   else {
-    tok.skip();
+    tok.skip_spaces();
     return !(tok.is_newline() || tok.is_eof());
   }
 }
@@ -3014,7 +3014,7 @@ symbol read_identifier(bool required)
 {
   if (want_att_compat) {
     char buf[3];
-    tok.skip();
+    tok.skip_spaces();
     if ((buf[0] = tok.ch()) != 0) {
       tok.next();
       if ((buf[1] = tok.ch()) != 0) {
@@ -3041,7 +3041,7 @@ symbol get_long_name(bool required)
 
 static symbol do_get_long_name(bool required, char end_char)
 {
-  tok.skip();
+  tok.skip_spaces();
   int buf_size = default_buffer_size;
   char *buf = 0 /* nullptr */;
   try {
@@ -4901,7 +4901,7 @@ static const char *character_mode_description(char_mode 
mode)
 void define_character(char_mode mode, const char *font_name)
 {
   const char *modestr = character_mode_description(mode);
-  tok.skip();
+  tok.skip_spaces();
   charinfo *ci = tok.get_charinfo(true /* required */);
   if (0 /* nullptr */ == ci) {
     skip_line();
@@ -4994,7 +4994,7 @@ static void print_character_request()
   }
   charinfo *ci;
   do {
-    tok.skip();
+    tok.skip_spaces();
     ci = tok.get_charinfo(false /* required */,
                          true /* suppress creation */);
     if (!tok.is_character()) {
@@ -6159,7 +6159,7 @@ static void do_register() // \R
   symbol nm = get_long_name(true /* required */);
   if (nm.is_null())
     return;
-  tok.skip();
+  tok.skip_spaces();
   reg *r = static_cast<reg *>(register_dictionary.lookup(nm));
   int prev_value;
   if ((0 /* nullptr */ == r) || !r->get_value(&prev_value))
@@ -6865,7 +6865,7 @@ static void take_branch()
 
 static void nop_request()
 {
-  tok.skip();
+  tok.skip_spaces();
 }
 
 // Perform a (formatted) output comparison operation, as found in
@@ -6922,7 +6922,7 @@ static bool is_conditional_expression_true()
 {
   bool perform_output_comparison = false;
   bool want_test_sense_inverted = false;
-  tok.skip();
+  tok.skip_spaces();
   while (tok.ch() == '!') {
     tok.next();
     want_test_sense_inverted = !want_test_sense_inverted;
@@ -6988,7 +6988,7 @@ static bool is_conditional_expression_true()
   }
   else if (c == 'c') {
     tok.next();
-    tok.skip();
+    tok.skip_spaces();
     charinfo *ci = tok.get_charinfo(true /* required */);
     if (ci == 0 /* nullptr */) {
       skip_branch();
@@ -8295,7 +8295,7 @@ static void init_hpf_code_table()
 
 static void do_translate(bool transparently, bool as_input)
 {
-  tok.skip();
+  tok.skip_spaces();
   while (!tok.is_newline() && !tok.is_eof()) {
     if (tok.is_space()) {
       // This is a really bizarre troff feature.
@@ -8479,7 +8479,7 @@ static void set_hyphenation_codes()
        && cidst->get_translation()->is_translatable_as_input())
       cidst->get_translation()->set_hyphenation_code(new_code);
     tok.next();
-    tok.skip();
+    tok.skip_spaces();
   }
   skip_line();
 }
@@ -8503,7 +8503,7 @@ void hyphenation_patterns_file_code()
       }
       if (read_integer(&n2) && ((0 <= n2) && (n2 <= 255))) {
        hpf_code_table[n1] = n2;
-       tok.skip();
+       tok.skip_spaces();
       }
       else {
        error("output hyphenation code must be integer in the range 0..255");
@@ -8522,7 +8522,7 @@ dictionary char_class_dictionary(501);
 
 static void define_class_request()
 {
-  tok.skip();
+  tok.skip_spaces();
   symbol nm = read_identifier(true /* required */);
   if (nm.is_null()) {
     skip_line();
@@ -8536,7 +8536,7 @@ static void define_class_request()
   charinfo *child1 = 0 /* nullptr */, *child2 = 0 /* nullptr */;
   bool just_chained_a_range_expression = false;
   while (!tok.is_newline() && !tok.is_eof()) {
-    tok.skip();
+    tok.skip_spaces();
     // Chained range expressions like
     //   \[u3041]-\[u3096]-\[u30FF]
     // are not valid.
@@ -8681,7 +8681,7 @@ charinfo *token::get_charinfo(bool required, bool 
suppress_creation)
 
 charinfo *read_character(/* TODO?: bool required */)
 {
-  tok.skip();
+  tok.skip_spaces();
   charinfo *ci = tok.get_charinfo();
   // TODO?: if (required && (0 /* nullptr */ == ci))
   if (0 /* nullptr */ == ci)
@@ -10151,7 +10151,7 @@ static node *read_drawing_command() // \D
          break;
        }
        ++npoints;
-       tok.skip();
+       tok.skip_spaces();
        point[i].v = V0;
        if (tok == start_token) {
          no_last_v = true;
@@ -10161,7 +10161,7 @@ static node *read_drawing_command() // \D
          had_error = false;
          break;
        }
-       tok.skip();
+       tok.skip_spaces();
       }
       while (tok != start_token && !tok.is_newline() && !tok.is_eof())
        tok.next();
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index bcfd5c103..5a7b69183 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6965,7 +6965,7 @@ bool is_valid_font_mounting_position(int n)
 static bool read_font_identifier(font_lookup_info *finfo)
 {
   int n;
-  tok.skip();
+  tok.skip_spaces();
   if (tok.is_usable_as_delimiter()) {
     symbol s = read_identifier(true /* required */);
     finfo->requested_name = const_cast<char *>(s.contents());
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index 7543b7d16..3de389b9d 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -263,7 +263,7 @@ static bool is_valid_expression(units *u, int scaling_unit,
                             is_mandatory);
   while (result) {
     if (is_parenthesized)
-      tok.skip();
+      tok.skip_spaces();
     int op = tok.ch();
     switch (op) {
     case '+':
@@ -445,7 +445,7 @@ static bool is_valid_term(units *u, int scaling_unit,
     if (!is_valid_expression(u, scaling_unit,
                             true /* is_parenthesized */, is_mandatory))
       return false;
-    tok.skip();
+    tok.skip_spaces();
     if (tok.ch() != ')') {
       if (is_mandatory)
        return false;
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index b4565cdf9..5ef2e2c76 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -447,7 +447,7 @@ void assign_register_format_request()
     r = new number_reg;
     register_dictionary.define(nm, r);
   }
-  tok.skip();
+  tok.skip_spaces();
   char c = tok.ch();
   if (csdigit(c)) {
     int n = 0;
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index a56062fe8..f24b6d8df 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -80,7 +80,7 @@ public:
   void operator=(const token &);
   void next();
   void process();
-  void skip();
+  void skip_spaces();
   int nspaces();               // is_space() as integer
   bool is_eof();
   bool is_space();

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

Reply via email to