gbranden pushed a commit to branch master
in repository groff.

commit 6cf47ebb1986c3bc172a23d29c79a920241e89af
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Dec 19 12:24:37 2025 -0600

    [troff]: Trivially refactor.
    
    * src/roff/troff/hvunits.h (get_vunits, get_hunits): Rename (in
      declarations) these...
      (read_vunits, read_hunits): ...to these, because they advance
      the input stream pointer.
    
    * src/roff/troff/number.cpp (get_vunits, get_hunits): Rename (in
      definitions) these...
      (read_vunits, read_hunits): ...to these.  Update literals in
      assertions.
    
    * src/roff/troff/column.cpp (column_justify) [COLUMN]:
    * src/roff/troff/div.cpp (page_offset, when_request)
      (space_request, need_space, save_vertical_space, diversion_trap)
      (change_trap, return_request):
    * src/roff/troff/env.cpp (line_length, title_length)
      (vertical_spacing, post_vertical_spacing, indent)
      (temporary_indent, margin_character, hyphenation_space_request)
      (hyphenation_margin_request, configure_tab_stops_request): Update call
      sites.
---
 ChangeLog                 | 22 ++++++++++++++++++++++
 src/roff/troff/column.cpp |  6 +++---
 src/roff/troff/div.cpp    | 20 ++++++++++----------
 src/roff/troff/env.cpp    | 20 ++++++++++----------
 src/roff/troff/hvunits.h  |  8 ++++----
 src/roff/troff/input.cpp  |  6 +++---
 src/roff/troff/node.cpp   |  4 ++--
 src/roff/troff/number.cpp | 12 ++++++------
 8 files changed, 60 insertions(+), 38 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7b0fb386a..ee1d4136a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2025-12-19  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor.
+
+       * src/roff/troff/hvunits.h (get_vunits, get_hunits): Rename (in
+       declarations) these...
+       (read_vunits, read_hunits): ...to these, because they advance
+       the input stream pointer.
+       * src/roff/troff/number.cpp (get_vunits, get_hunits): Rename (in
+       definitions) these...
+       (read_vunits, read_hunits): ...to these.  Update literals in
+       assertions.
+       * src/roff/troff/column.cpp (column_justify) [COLUMN]:
+       * src/roff/troff/div.cpp (page_offset, when_request)
+       (space_request, need_space, save_vertical_space, diversion_trap)
+       (change_trap, return_request):
+       * src/roff/troff/env.cpp (line_length, title_length)
+       (vertical_spacing, post_vertical_spacing, indent)
+       (temporary_indent, margin_character, hyphenation_space_request)
+       (hyphenation_margin_request, configure_tab_stops_request):
+       Update call sites.
+
 2025-12-19  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/number.cpp: Drop unnecessary header file
diff --git a/src/roff/troff/column.cpp b/src/roff/troff/column.cpp
index 81ea311a6..73c58580e 100644
--- a/src/roff/troff/column.cpp
+++ b/src/roff/troff/column.cpp
@@ -551,12 +551,12 @@ static void column_justify()
   vunits height;
   if (!the_column->is_active())
     error("can't justify column - column not active");
-  else if (get_vunits(&height, 'v')) {
+  else if (read_vunits(&height, 'v')) {
     justification_spec js(height);
     symbol nm = get_long_name(true /* required */);
     if (!nm.is_null()) {
       vunits v;
-      if (get_vunits(&v, 'v')) {
+      if (read_vunits(&v, 'v')) {
        js.append(nm, v);
        int err = 0;
        while (has_arg()) {
@@ -565,7 +565,7 @@ static void column_justify()
            err = 1;
            break;
          }
-         if (!get_vunits(&v, 'v')) {
+         if (!read_vunits(&v, 'v')) {
            err = 1;
            break;
          }
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index d720f6162..ed5b8e727 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -741,7 +741,7 @@ void page_offset()
   // The troff manual says that the default scaling indicator is v,
   // but it is in fact m: v wouldn't make sense for a horizontally
   // oriented request.
-  if (!has_arg() || !get_hunits(&n, 'm', topdiv->page_offset))
+  if (!has_arg() || !read_hunits(&n, 'm', topdiv->page_offset))
     n = topdiv->prev_page_offset;
   topdiv->prev_page_offset = topdiv->page_offset;
   topdiv->page_offset = n;
@@ -752,7 +752,7 @@ void page_offset()
 static void page_length()
 {
   vunits temp;
-  if (has_arg() && get_vunits(&temp, 'v', topdiv->get_page_length())) {
+  if (has_arg() && read_vunits(&temp, 'v', topdiv->get_page_length())) {
     if (temp < vresolution) {
       warning(WARN_RANGE, "setting computed page length %1u to device"
                          " vertical motion quantum",
@@ -769,7 +769,7 @@ static void page_length()
 static void when_request()
 {
   vunits n;
-  if (get_vunits(&n, 'v')) {
+  if (read_vunits(&n, 'v')) {
     symbol s = read_identifier();
     if (s.is_null())
       topdiv->remove_trap_at(n);
@@ -862,7 +862,7 @@ static void space_request()
   if (want_break)
     curenv->do_break();
   vunits n;
-  if (!has_arg() || !get_vunits(&n, 'v'))
+  if (!has_arg() || !read_vunits(&n, 'v'))
     n = curenv->get_vertical_spacing();
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
@@ -890,7 +890,7 @@ BEGIN_TRAP token is not skipped over. */
 static void need_space()
 {
   vunits n;
-  if (!has_arg() || !get_vunits(&n, 'v'))
+  if (!has_arg() || !read_vunits(&n, 'v'))
     n = curenv->get_vertical_spacing();
   while (!tok.is_newline() && !tok.is_eof())
     tok.next();
@@ -923,7 +923,7 @@ vunits saved_space;
 static void save_vertical_space()
 {
   vunits x;
-  if (!has_arg() || !get_vunits(&x, 'v'))
+  if (!has_arg() || !read_vunits(&x, 'v'))
     x = curenv->get_vertical_spacing();
   if (curdiv->distance_to_next_trap() > x)
     curdiv->space(x, true /* forcing */);
@@ -977,7 +977,7 @@ void top_level_diversion::clear_diversion_trap()
 static void diversion_trap()
 {
   vunits n;
-  if (has_arg() && get_vunits(&n, 'v')) {
+  if (has_arg() && read_vunits(&n, 'v')) {
     symbol s = read_identifier();
     if (!s.is_null())
       curdiv->set_diversion_trap(s, n);
@@ -994,7 +994,7 @@ static void change_trap()
   symbol s = read_identifier(true /* required */);
   if (!s.is_null()) {
     vunits x;
-    if (has_arg() && get_vunits(&x, 'v'))
+    if (has_arg() && read_vunits(&x, 'v'))
       topdiv->change_trap(s, x);
     else
       topdiv->remove_trap(s);
@@ -1029,12 +1029,12 @@ static void return_request()
     if (tok.ch() == int('-')) { // TODO: grochar
       tok.next();
       vunits x;
-      if (get_vunits(&x, 'v'))
+      if (read_vunits(&x, 'v'))
        dist = -x;
     }
     else {
       vunits x;
-      if (get_vunits(&x, 'v'))
+      if (read_vunits(&x, 'v'))
        dist = x >= V0 ? x - curdiv->get_vertical_position() : V0;
     }
   }
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 112f603df..44de954b8 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1493,7 +1493,7 @@ void right_justify()
 void line_length()
 {
   hunits temp;
-  if (has_arg() && get_hunits(&temp, 'm', curenv->line_length)) {
+  if (has_arg() && read_hunits(&temp, 'm', curenv->line_length)) {
     if (temp < hresolution) {
       warning(WARN_RANGE, "setting computed line length %1u to device"
                          " horizontal motion quantum",
@@ -1512,7 +1512,7 @@ void line_length()
 void title_length()
 {
   hunits temp;
-  if (has_arg() && get_hunits(&temp, 'm', curenv->title_length)) {
+  if (has_arg() && read_hunits(&temp, 'm', curenv->title_length)) {
     if (temp < hresolution) {
       warning(WARN_RANGE, "setting computed title length %1u to device"
                          " horizontal motion quantum",
@@ -1530,7 +1530,7 @@ void title_length()
 void vertical_spacing()
 {
   vunits temp;
-  if (has_arg() && get_vunits(&temp, 'p', curenv->vertical_spacing)) {
+  if (has_arg() && read_vunits(&temp, 'p', curenv->vertical_spacing)) {
     if (temp < V0) {
       warning(WARN_RANGE, "vertical spacing must be nonnegative");
       temp = vresolution;
@@ -1546,7 +1546,7 @@ void vertical_spacing()
 void post_vertical_spacing()
 {
   vunits temp;
-  if (has_arg() && get_vunits(&temp, 'p',
+  if (has_arg() && read_vunits(&temp, 'p',
                              curenv->post_vertical_spacing)) {
     if (temp < V0) {
       warning(WARN_RANGE, "post-vertical spacing must be nonnegative");
@@ -1580,7 +1580,7 @@ void line_spacing()
 void indent()
 {
   hunits temp;
-  if (has_arg() && get_hunits(&temp, 'm', curenv->indent)) {
+  if (has_arg() && read_hunits(&temp, 'm', curenv->indent)) {
     if (temp < H0) {
       warning(WARN_RANGE, "treating %1u indentation as zero",
              temp.to_units());
@@ -1612,7 +1612,7 @@ void temporary_indent()
     // character this request still breaks the line.
   }
   else {
-    if (!get_hunits(&temp, 'm', curenv->get_indent()))
+    if (!read_hunits(&temp, 'm', curenv->get_indent()))
       is_valid = false;
     while (!tok.is_newline() && !tok.is_eof())
       tok.next();
@@ -1693,7 +1693,7 @@ void margin_character()
       curenv->margin_character_flags = environment::MC_ON
                                       | environment::MC_NEXT;
       hunits d;
-      if (has_arg() && get_hunits(&d, 'm'))
+      if (has_arg() && read_hunits(&d, 'm'))
        curenv->margin_character_distance = d;
     }
   }
@@ -2020,7 +2020,7 @@ hunits environment::get_hyphenation_space()
 void hyphenation_space_request()
 {
   hunits n;
-  if (get_hunits(&n, 'm')) {
+  if (read_hunits(&n, 'm')) {
     if (n < H0) {
       warning(WARN_RANGE, "hyphenation space cannot be negative");
       n = H0;
@@ -2038,7 +2038,7 @@ hunits environment::get_hyphenation_margin()
 void hyphenation_margin_request()
 {
   hunits n;
-  if (get_hunits(&n, 'm')) {
+  if (read_hunits(&n, 'm')) {
     if (n < H0) {
       warning(WARN_RANGE, "hyphenation margin cannot be negative");
       n = H0;
@@ -3013,7 +3013,7 @@ static void configure_tab_stops_request()
       is_repeating_stop = true;
       prev_pos = 0;
     }
-    if (!get_hunits(&pos, 'm', prev_pos))
+    if (!read_hunits(&pos, 'm', prev_pos))
       break;
     tab_type type = TAB_LEFT;
     if (tok.ch() == int('C')) { // TODO: grochar
diff --git a/src/roff/troff/hvunits.h b/src/roff/troff/hvunits.h
index e15855a52..25b10ba96 100644
--- a/src/roff/troff/hvunits.h
+++ b/src/roff/troff/hvunits.h
@@ -76,10 +76,10 @@ public:
 
 extern const hunits H0;
 
-extern bool get_vunits(vunits *, unsigned char si);
-extern bool get_hunits(hunits *, unsigned char si);
-extern bool get_vunits(vunits *, unsigned char si, vunits prev_value);
-extern bool get_hunits(hunits *, unsigned char si, hunits prev_value);
+extern bool read_vunits(vunits *, unsigned char si);
+extern bool read_hunits(hunits *, unsigned char si);
+extern bool read_vunits(vunits *, unsigned char si, vunits prev_value);
+extern bool read_hunits(hunits *, unsigned char si, hunits prev_value);
 
 inline vunits:: vunits() : n(0)
 {
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 58c9df9d8..b53ab799f 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8423,7 +8423,7 @@ void warnscale_request()
 void spreadwarn_request()
 {
   hunits n;
-  if (has_arg() && get_hunits(&n, 'm')) {
+  if (has_arg() && read_hunits(&n, 'm')) {
     if (n < 0)
       n = 0;
     hunits em = curenv->get_size();
@@ -10349,7 +10349,7 @@ static node *read_drawing_command() // \D
          had_error = true;
          break;
        }
-       if (!get_hunits(&point[i].h,
+       if (!read_hunits(&point[i].h,
                        type == 'f' || type == 't' ? 'u' : 'm')) {
          had_error = true;
          break;
@@ -10361,7 +10361,7 @@ static node *read_drawing_command() // \D
          no_last_v = true;
          break;
        }
-       if (!get_vunits(&point[i].v, 'v')) {
+       if (!read_vunits(&point[i].v, 'v')) {
          had_error = false;
          break;
        }
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index b441683cb..bce5060e7 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -7430,9 +7430,9 @@ static void configure_track_kerning()
     hunits min_a, max_a;
     if (has_arg()
        && read_measurement(&min_s, 'z')
-       && get_hunits(&min_a, 'p')
+       && read_hunits(&min_a, 'p')
        && read_measurement(&max_s, 'z')
-       && get_hunits(&max_a, 'p')) {
+       && read_hunits(&max_a, 'p')) {
       track_kerning_function tk(min_s, min_a, max_s, max_a);
       font_table[n]->set_track_kern(tk);
     }
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index 948a8fe80..12b602238 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -44,7 +44,7 @@ static bool is_valid_expression(units *u, int scaling_unit,
                                bool is_mandatory = false);
 static bool is_valid_expression_start();
 
-bool get_vunits(vunits *res, unsigned char si)
+bool read_vunits(vunits *res, unsigned char si)
 {
   if (!is_valid_expression_start())
     return false;
@@ -57,7 +57,7 @@ bool get_vunits(vunits *res, unsigned char si)
     return false;
 }
 
-bool get_hunits(hunits *res, unsigned char si)
+bool read_hunits(hunits *res, unsigned char si)
 {
   if (!is_valid_expression_start())
     return false;
@@ -117,7 +117,7 @@ enum incr_number_result { INVALID, ASSIGN, INCREMENT, 
DECREMENT };
 
 static incr_number_result get_incr_number(units *res, unsigned char);
 
-bool get_vunits(vunits *res, unsigned char si, vunits prev_value)
+bool read_vunits(vunits *res, unsigned char si, vunits prev_value)
 {
   units v;
   // Use a primitive temporary because having the ckd macros store to
@@ -140,12 +140,12 @@ bool get_vunits(vunits *res, unsigned char si, vunits 
prev_value)
     *res = i;
     break;
   default:
-    assert(0 == "unhandled case in get_vunits()");
+    assert(0 == "unhandled case in read_vunits()");
   }
   return true;
 }
 
-bool get_hunits(hunits *res, unsigned char si, hunits prev_value)
+bool read_hunits(hunits *res, unsigned char si, hunits prev_value)
 {
   units h;
   // Use a primitive temporary because having the ckd macros store to
@@ -168,7 +168,7 @@ bool get_hunits(hunits *res, unsigned char si, hunits 
prev_value)
     *res = i;
     break;
   default:
-    assert(0 == "unhandled case in get_hunits()");
+    assert(0 == "unhandled case in read_hunits()");
   }
   return true;
 }

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

Reply via email to