gbranden pushed a commit to branch master
in repository groff.

commit 5b8433135c19f8834d4b8f61a19f15016071d533
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 16 17:03:04 2025 -0600

    [troff]: Trivially refactor.
    
    Rename `get_integer()` to `read_integer()` because it does more than
    retrieve a property; it advances the input stream pointer.
    
    * src/roff/troff/token.h (get_integer): Rename this declaration...
      (read_integer): ...to this.
    
    * src/roff/troff/number.cpp (get_integer): Rename this definition...
      (read_integer): ...to this.  Also update assertion text.
    
    * src/roff/troff/div.cpp (begin_page, page_number)
      (return_request):
    * src/roff/troff/env.cpp (window_control_request) [0]
      (space_size, no_fill, center, right_justify)
      (post_vertical_spacing, temporary_indent, number_lines)
      (hyphenate_request, set_hyphenation_mode_default)
      (hyphenation_line_max_request, adjust, do_input_trap)
      (field_characters_request):
    * src/roff/troff/input.cpp (shift, activate_color, compatible)
      (substring_request, line_file, set_character_flags_request)
      (hyphenation_patterns_file_code, set_warning_mask_request):
    * src/roff/troff/node.cpp (mount_font_at_position)
      (associate_style_with_font_position, read_font_identifier)
      (zoom_font, constantly_space_font, set_ligature_mode)
      (set_kerning_mode): Update call sites.
---
 ChangeLog                 | 29 +++++++++++++++++++++++++++++
 src/roff/troff/div.cpp    |  6 +++---
 src/roff/troff/env.cpp    | 38 +++++++++++++++++++-------------------
 src/roff/troff/input.cpp  | 20 ++++++++++----------
 src/roff/troff/node.cpp   | 14 +++++++-------
 src/roff/troff/number.cpp |  6 +++---
 src/roff/troff/token.h    |  4 ++--
 7 files changed, 73 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 15be52b7e..73bb1caf8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2025-11-16  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor.  Rename `get_integer()` to
+       `read_integer()` because it does more than retrieve a property;
+       it advances the input stream pointer.
+
+       * src/roff/troff/token.h (get_integer): Rename this
+       declaration...
+       (read_integer): ...to this.
+       * src/roff/troff/number.cpp (get_integer): Rename this
+       definition...
+       (read_integer): ...to this.  Also update assertion text.
+
+       * src/roff/troff/div.cpp (begin_page, page_number)
+       (return_request):
+       * src/roff/troff/env.cpp (window_control_request) [0]
+       (space_size, no_fill, center, right_justify)
+       (post_vertical_spacing, temporary_indent, number_lines)
+       (hyphenate_request, set_hyphenation_mode_default)
+       (hyphenation_line_max_request, adjust, do_input_trap)
+       (field_characters_request):
+       * src/roff/troff/input.cpp (shift, activate_color, compatible)
+       (substring_request, line_file, set_character_flags_request)
+       (hyphenation_patterns_file_code, set_warning_mask_request):
+       * src/roff/troff/node.cpp (mount_font_at_position)
+       (associate_style_with_font_position, read_font_identifier)
+       (zoom_font, constantly_space_font, set_ligature_mode)
+       (set_kerning_mode): Update call sites.
+
 2025-11-16  G. Branden Robinson <[email protected]>
 
        * src/preproc/tbl/table.cpp: Trivially refactor.  Update
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index aa1df9858..3d8abc179 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -781,7 +781,7 @@ void begin_page()
 {
   bool got_arg = false;
   int n = 0;
-  if (has_arg() && get_integer(&n, topdiv->get_page_number()))
+  if (has_arg() && read_integer(&n, topdiv->get_page_number()))
     got_arg = true;
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
@@ -911,7 +911,7 @@ void page_number()
   // register before invoking .pn.
   reg *r = static_cast<reg *>(register_dictionary.lookup("ps4html"));
   if (0 /* nullptr */ == r)
-    if (has_arg() && get_integer(&n, topdiv->get_page_number()))
+    if (has_arg() && read_integer(&n, topdiv->get_page_number()))
       topdiv->set_next_page_number(n);
   skip_line();
 }
@@ -1044,7 +1044,7 @@ void return_request()
 void vertical_position_traps()
 {
   int n = 0;
-  if (has_arg() && get_integer(&n))
+  if (has_arg() && read_integer(&n))
     honor_vertical_position_traps = (n > 0);
   else
     honor_vertical_position_traps = true;
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 7a58fbf8d..d47ce17b9 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -227,7 +227,7 @@ void environment::mark_last_line()
 void widow_control_request()
 {
   int n;
-  if (has_arg() && get_integer(&n))
+  if (has_arg() && read_integer(&n))
     curenv->want_widow_control = (n > 0);
   else
     curenv->want_widow_control = true;
@@ -1419,12 +1419,12 @@ void space_size()
     return;
   }
   int n;
-  if (get_integer(&n)) {
+  if (read_integer(&n)) {
     if (n < 0)
       warning(WARN_RANGE, "ignoring negative word space size: '%1'", n);
     else
       curenv->space_size = n;
-    if (has_arg() && get_integer(&n))
+    if (has_arg() && read_integer(&n))
       if (n < 0)
        warning(WARN_RANGE, "ignoring negative sentence space size: "
                "'%1'", n);
@@ -1460,7 +1460,7 @@ void no_fill()
 void center()
 {
   int n;
-  if (!has_arg() || !get_integer(&n))
+  if (!has_arg() || !read_integer(&n))
     n = 1;
   else if (n < 0)
     n = 0;
@@ -1477,7 +1477,7 @@ void center()
 void right_justify()
 {
   int n;
-  if (!has_arg() || !get_integer(&n))
+  if (!has_arg() || !read_integer(&n))
     n = 1;
   else if (n < 0)
     n = 0;
@@ -1564,7 +1564,7 @@ void post_vertical_spacing()
 void line_spacing()
 {
   int temp;
-  if (has_arg() && get_integer(&temp)) {
+  if (has_arg() && read_integer(&temp)) {
     if (temp < 1) {
       warning(WARN_RANGE, "value %1 out of range: interpreted as 1", temp);
       temp = 1;
@@ -1635,7 +1635,7 @@ void temporary_indent()
 void configure_underlining(bool want_spaces_underlined)
 {
   int n;
-  if (!has_arg() || !get_integer(&n))
+  if (!has_arg() || !read_integer(&n))
     n = 1;
   if (n <= 0) {
     if (curenv->underlined_line_count > 0) {
@@ -1720,7 +1720,7 @@ void number_lines()
     curenv->line_number_digit_width = env_digit_width(curenv);
     int n;
     if (!tok.is_usable_as_delimiter()) { // XXX abuse of function
-      if (get_integer(&n, next_line_number)) {
+      if (read_integer(&n, next_line_number)) {
        next_line_number = n;
        if (next_line_number < 0) {
          warning(WARN_RANGE, "output line number cannot be negative");
@@ -1733,7 +1733,7 @@ void number_lines()
        tok.next();
     if (has_arg()) {
       if (!tok.is_usable_as_delimiter()) { // XXX abuse of function
-       if (get_integer(&n)) {
+       if (read_integer(&n)) {
          if (n <= 0) {
            warning(WARN_RANGE, "output line number multiple cannot"
                    "be nonpositive");
@@ -1747,14 +1747,14 @@ void number_lines()
          tok.next();
       if (has_arg()) {
        if (!tok.is_usable_as_delimiter()) { // XXX abuse of function
-         if (get_integer(&n))
+         if (read_integer(&n))
            curenv->number_text_separation = n;
        }
        else
          while (!tok.is_space() && !tok.is_newline() && !tok.is_eof())
            tok.next();
        if (has_arg() && !tok.is_usable_as_delimiter() // XXX abuse of function
-           && get_integer(&n))
+           && read_integer(&n))
          curenv->line_number_indent = n;
       }
     }
@@ -1765,7 +1765,7 @@ void number_lines()
 void no_number()
 {
   int n;
-  if (has_arg() && get_integer(&n))
+  if (has_arg() && read_integer(&n))
     curenv->no_number_count = n > 0 ? n : 0;
   else
     curenv->no_number_count = 1;
@@ -1781,7 +1781,7 @@ void no_hyphenate()
 void hyphenate_request()
 {
   int n;
-  if (has_arg() && get_integer(&n)) {
+  if (has_arg() && read_integer(&n)) {
     if (n < HYPHEN_NONE) {
       warning(WARN_RANGE, "ignoring negative hyphenation mode: %1", n);
     } else if (n > HYPHEN_MAX) {
@@ -1809,8 +1809,8 @@ void set_hyphenation_mode_default()
     return;
   }
   int n;
-  if (!get_integer(&n)) {
-    // get_integer() will throw a diagnostic if necessary.
+  if (!read_integer(&n)) {
+    // read_integer() will throw a diagnostic if necessary.
     skip_line();
     return;
   }
@@ -1836,7 +1836,7 @@ void hyphenation_character_request()
 void hyphen_line_max_request()
 {
   int n;
-  if (has_arg() && get_integer(&n))
+  if (has_arg() && read_integer(&n))
     curenv->hyphen_line_max = n;
   else
     curenv->hyphen_line_max = -1;
@@ -2751,7 +2751,7 @@ void adjust()
       break;
     default:
       int n;
-      if (get_integer(&n)) {
+      if (read_integer(&n)) {
        if (n < 0)
          warning(WARN_RANGE, "negative adjustment mode");
        else if (n > ADJUST_MAX)
@@ -2778,7 +2778,7 @@ void do_input_trap(bool respect_continuation)
   curenv->input_trap = 0 /* nullptr */;
   curenv->continued_input_trap = respect_continuation;
   int n;
-  if (has_arg() && get_integer(&n)) {
+  if (has_arg() && read_integer(&n)) {
     if (n <= 0)
       warning(WARN_RANGE,
              "input trap line count must be greater than zero");
@@ -3076,7 +3076,7 @@ static void field_characters_request()
 void line_tabs_request()
 {
   int n;
-  if (has_arg() && get_integer(&n))
+  if (has_arg() && read_integer(&n))
     curenv->using_line_tabs = (n > 0);
   else
     curenv->using_line_tabs = true;
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index f7b8402e0..6c128d525 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -940,7 +940,7 @@ void next_file()
 void shift()
 {
   int n;
-  if (!has_arg() || !get_integer(&n))
+  if (!has_arg() || !read_integer(&n))
     n = 1;
   input_stack::shift(n);
   skip_line();
@@ -1530,7 +1530,7 @@ static void activate_color()
 {
   int n;
   bool is_color_desired = false;
-  if (has_arg() && get_integer(&n))
+  if (has_arg() && read_integer(&n))
     is_color_desired = (n > 0);
   else
     is_color_desired = true;
@@ -2966,7 +2966,7 @@ void skip_line()
 void compatible()
 {
   int n;
-  if (has_arg() && get_integer(&n))
+  if (has_arg() && read_integer(&n))
     want_att_compat = (n > 0);
   else
     want_att_compat = true;
@@ -5598,14 +5598,14 @@ void substring_request()
   int start;                   // 0, 1, ..., n-1  or  -1, -2, ...
   symbol s = read_identifier();
   assert(s != 0 /* nullptr */);
-  if (!s.is_null() && get_integer(&start)) {
+  if (!s.is_null() && read_integer(&start)) {
     request_or_macro *p = lookup_request(s);
     macro *m = p->to_macro();
     if (!m)
       error("cannot extract substring of request '%1'", s.contents());
     else {
       int end = -1;
-      if (!has_arg() || get_integer(&end)) {
+      if (!has_arg() || read_integer(&end)) {
        int real_length = 0;                    // 1, 2, ..., n
        string_iterator iter1(*m);
        for (int l = 0; l < m->len; l++) {
@@ -6783,7 +6783,7 @@ int get_file_line(const char **filename, int *lineno)
 void line_file()
 {
   int n;
-  if (get_integer(&n)) {
+  if (read_integer(&n)) {
     if (has_arg(true /* peek */)) {
       const char *reported_file_name = read_rest_of_line_as_argument();
       (void) input_stack::set_location(reported_file_name, (n - 1));
@@ -8384,7 +8384,7 @@ static void set_character_flags_request()
     return;
   }
   int flags;
-  if (get_integer(&flags)) {
+  if (read_integer(&flags)) {
     if ((flags < 0) || (flags > charinfo::CFLAGS_MAX)) {
       warning(WARN_RANGE, "character flags must be in range 0..%1,"
              " got %2", charinfo::CFLAGS_MAX, flags);
@@ -8497,12 +8497,12 @@ void hyphenation_patterns_file_code()
   }
   while (!tok.is_newline() && !tok.is_eof()) {
     int n1, n2;
-    if (get_integer(&n1) && (0 <= n1 && n1 <= 255)) {
+    if (read_integer(&n1) && (0 <= n1 && n1 <= 255)) {
       if (!has_arg()) {
        error("missing output hyphenation code");
        break;
       }
-      if (get_integer(&n2) && (0 <= n2 && n2 <= 255)) {
+      if (read_integer(&n2) && (0 <= n2 && n2 <= 255)) {
        hpf_code_table[n1] = n2;
        tok.skip();
       }
@@ -9802,7 +9802,7 @@ int main(int argc, char **argv)
 void set_warning_mask_request()
 {
   int n;
-  if (has_arg() && get_integer(&n)) {
+  if (has_arg() && read_integer(&n)) {
     if (n & ~WARN_MAX) {
       warning(WARN_RANGE, "warning mask must be in range 0..%1, got %2",
              WARN_MAX, n);
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 92553bb1d..106d108c0 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6802,7 +6802,7 @@ static void mount_font_at_position()
     return;
   }
   int n;
-  if (get_integer(&n)) {
+  if (read_integer(&n)) {
     if (n < 0)
       error("font mounting position %1 is negative", n);
     else {
@@ -6923,7 +6923,7 @@ static void associate_style_with_font_position()
     return;
   }
   int n;
-  if (get_integer(&n)) {
+  if (read_integer(&n)) {
     if (n < 0)
       error("font mounting position %1 is negative", n);
     else {
@@ -6979,7 +6979,7 @@ static bool read_font_identifier(font_lookup_info *finfo)
       finfo->position = curenv->get_family()->resolve(n);
     }
   }
-  else if (get_integer(&n)) {
+  else if (read_integer(&n)) {
     finfo->requested_position = n;
     if (is_valid_font_mounting_position(n))
       finfo->position = curenv->get_family()->resolve(n);
@@ -7163,7 +7163,7 @@ static void zoom_font()
   }
 #endif
   int zoom = 0;
-  get_integer(&zoom);
+  read_integer(&zoom);
   if (zoom < 0) {
     warning(WARN_RANGE, "ignoring negative font zoom factor '%1'",
            zoom);
@@ -7445,7 +7445,7 @@ static void constantly_space_font()
     font_lookup_error(finfo, "for constant spacing");
   else {
     int n = finfo.position, x, y;
-    if (!has_arg() || !get_integer(&x))
+    if (!has_arg() || !read_integer(&x))
       font_table[n]->set_constant_space(CONSTANT_SPACE_NONE);
     else {
       if (!has_arg() || !read_measurement(&y, 'z'))
@@ -7463,7 +7463,7 @@ static void constantly_space_font()
 static void set_ligature_mode()
 {
   int lig;
-  if (has_arg() && get_integer(&lig) && lig >= 0 && lig <= 2)
+  if (has_arg() && read_integer(&lig) && lig >= 0 && lig <= 2)
     global_ligature_mode = lig;
   else
     global_ligature_mode = 1;
@@ -7473,7 +7473,7 @@ static void set_ligature_mode()
 static void set_kerning_mode()
 {
   int k;
-  if (has_arg() && get_integer(&k))
+  if (has_arg() && read_integer(&k))
     global_kern_mode = (k > 0);
   else
     global_kern_mode = true;
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index 78b5de285..7543b7d16 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -98,7 +98,7 @@ bool read_measurement(units *res, unsigned char si)
     return false;
 }
 
-bool get_integer(int *res)
+bool read_integer(int *res)
 {
   if (!is_valid_expression_start())
     return false;
@@ -194,7 +194,7 @@ bool read_measurement(units *res, unsigned char si, units 
prev_value)
   return true;
 }
 
-bool get_integer(int *res, int prev_value)
+bool read_integer(int *res, int prev_value)
 {
   units i;
   switch (get_incr_number(&i, 0)) {
@@ -212,7 +212,7 @@ bool get_integer(int *res, int prev_value)
       warning(WARN_RANGE, "integer decrementation saturated");
     break;
   default:
-    assert(0 == "unhandled case in get_integer()");
+    assert(0 == "unhandled case in read_integer()");
   }
   return true;
 }
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index 697cb5142..549a51cc5 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -146,11 +146,11 @@ extern void read_title_parts(node **part, hunits 
*part_width);
 extern bool get_number_rigidly(units *result, unsigned char si);
 
 extern bool read_measurement(units *result, unsigned char si);
-extern bool get_integer(int *result);
+extern bool read_integer(int *result);
 
 extern bool read_measurement(units *result, unsigned char si,
                             units prev_value);
-extern bool get_integer(int *result, int prev_value);
+extern bool read_integer(int *result, int prev_value);
 
 extern void interpolate_register(symbol, int);
 

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

Reply via email to