gbranden pushed a commit to branch master
in repository groff.

commit 5e515b5565ae0225a9a8829737a05e6c1c182965
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Dec 19 14:35:44 2025 -0600

    [troff]: Trivially refactor.
    
    Rename `get_long_name()` to `read_long_identifer()`, because it's used
    for more than just reading "names" (request, macro, string, or diversion
    identifiers), but also identifiers of environments, colors, registers,
    fonts, styles, and file names.  (The last occurs only in
    `ps_bbox_request()` and might be inapposite; GNU troff now handles file
    names with spaces in thim, and that might not work because the `psbb`
    request is not parsing its arguments appropriately.)
    
    * src/roff/troff/token.h: Rename in declaration.
    
    * src/roff/troff/input.cpp (get_long_name): Rename this...
      (read_long_identifer): ...to this.
    
    * src/roff/troff/column.cpp (column_justify) [COLUMN]:
    * src/roff/troff/env.cpp (environment_copy, environment_switch):
    * src/roff/troff/input.cpp (define_color, read_identifier)
      (do_register, is_conditional_expression_true, ps_bbox_request)
      (vjustify) [COLUMN]:
    * src/roff/troff/node.cpp (mount_font_at_position): Update call sites.
---
 ChangeLog                 | 22 ++++++++++++++++++++++
 src/roff/troff/column.cpp |  4 ++--
 src/roff/troff/env.cpp    |  4 ++--
 src/roff/troff/input.cpp  | 20 ++++++++++----------
 src/roff/troff/node.cpp   |  2 +-
 src/roff/troff/token.h    |  2 +-
 6 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e8e8149ec..ebbd6bc05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2025-12-19  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor.  Rename `get_long_name()` to
+       `read_long_identifier()`, because it's used for more than just
+       reading "names" (request, macro, string, or diversion
+       identifiers), but also identifiers of environments, colors,
+       registers, fonts, styles, and file names.  (The last occurs only
+       in `ps_bbox_request()` and might be inapposite; GNU troff now
+       handles file names with spaces in thim, and that might not work
+       because the `psbb` request is not parsing its arguments
+       appropriately.)
+       * src/roff/troff/token.h: Rename in declaration.
+       * src/roff/troff/input.cpp (get_long_name): Rename this...
+       (read_long_identifier): ...to this.
+       * src/roff/troff/column.cpp (column_justify) [COLUMN]:
+       * src/roff/troff/env.cpp (environment_copy, environment_switch):
+       * src/roff/troff/input.cpp (define_color, read_identifier)
+       (do_register, is_conditional_expression_true, ps_bbox_request)
+       (vjustify) [COLUMN]:
+       * src/roff/troff/node.cpp (mount_font_at_position): Update call
+       sites.
+
 2025-12-19  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/token.h: Relocate declaration of "input.cpp"
diff --git a/src/roff/troff/column.cpp b/src/roff/troff/column.cpp
index 73c58580e..a5afb553d 100644
--- a/src/roff/troff/column.cpp
+++ b/src/roff/troff/column.cpp
@@ -553,14 +553,14 @@ static void column_justify()
     error("can't justify column - column not active");
   else if (read_vunits(&height, 'v')) {
     justification_spec js(height);
-    symbol nm = get_long_name(true /* required */);
+    symbol nm = read_long_identifier(true /* required */);
     if (!nm.is_null()) {
       vunits v;
       if (read_vunits(&v, 'v')) {
        js.append(nm, v);
        int err = 0;
        while (has_arg()) {
-         nm = get_long_name(true /* required */);
+         nm = read_long_identifier(true /* required */);
          if (nm.is_null()) {
            err = 1;
            break;
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 44de954b8..5b158f80d 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3775,7 +3775,7 @@ void environment_copy()
   }
   environment *e = 0 /* nullptr */;
   tok.skip_spaces();
-  symbol nm = get_long_name();
+  symbol nm = read_long_identifier();
   assert(nm != 0 /* nullptr */);
   e = static_cast<environment *>(env_dictionary.lookup(nm));
   if (e != 0 /* nullptr */)
@@ -3792,7 +3792,7 @@ void environment_switch()
     error("cannot switch out of dummy environment");
   }
   else {
-    symbol nm = get_long_name();
+    symbol nm = read_long_identifier();
     if (nm.is_null()) {
       if (env_stack == 0 /* nullptr */)
        error("environment stack underflow");
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ee292b68e..a48e975e7 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1583,7 +1583,7 @@ static void define_color()
     skip_line();
     return;
   }
-  symbol color_name = get_long_name();
+  symbol color_name = read_long_identifier();
   // Testing has_arg() should have ensured this.
   assert(color_name != 0 /* nullptr */);
   if (color_name == default_symbol) {
@@ -1591,7 +1591,7 @@ static void define_color()
     skip_line();
     return;
   }
-  symbol color_space = get_long_name();
+  symbol color_space = read_long_identifier();
   if (color_space.is_null()) {
     warning(WARN_MISSING, "missing color space in color definition"
            " request");
@@ -3165,10 +3165,10 @@ symbol read_identifier(bool required)
     }
   }
   else
-    return get_long_name(required);
+    return read_long_identifier(required);
 }
 
-symbol get_long_name(bool required)
+symbol read_long_identifier(bool required)
 {
   return read_input_until_terminator(required, 0U);
 }
@@ -6331,7 +6331,7 @@ static void do_register() // \R
     return;
 #endif
   tok.next();
-  symbol nm = get_long_name(true /* required */);
+  symbol nm = read_long_identifier(true /* required */);
   if (nm.is_null())
     return;
   tok.skip_spaces();
@@ -7162,7 +7162,7 @@ static bool is_conditional_expression_true()
   }
   else if (c == 'm') {
     tok.next();
-    symbol nm = get_long_name(true /* required */);
+    symbol nm = read_long_identifier(true /* required */);
     if (nm.is_null()) {
       skip_branch();
       return false;
@@ -7187,7 +7187,7 @@ static bool is_conditional_expression_true()
   }
   else if (c == 'F') {
     tok.next();
-    symbol nm = get_long_name(true /* required */);
+    symbol nm = read_long_identifier(true /* required */);
     if (nm.is_null()) {
       skip_branch();
       return false;
@@ -7196,7 +7196,7 @@ static bool is_conditional_expression_true()
   }
   else if (c == 'S') {
     tok.next();
-    symbol nm = get_long_name(true /* required */);
+    symbol nm = read_long_identifier(true /* required */);
     if (nm.is_null()) {
       skip_branch();
       return false;
@@ -7889,7 +7889,7 @@ void ps_bbox_request() // .psbb
   }
   // Parse input line, to extract file name.
   //
-  symbol nm = get_long_name(true /* required */);
+  symbol nm = read_long_identifier(true /* required */);
   if (nm.is_null())
     //
     // No file name specified: ignore the entire request.
@@ -9392,7 +9392,7 @@ void vjustify()
     handle_initial_request(VJUSTIFY_REQUEST);
     return;
   }
-  symbol type = get_long_name(true /* required */);
+  symbol type = read_long_identifier(true /* required */);
   if (!type.is_null())
     curdiv->vjustify(type);
   skip_line();
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index bce5060e7..bae4c7415 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6808,7 +6808,7 @@ static void mount_font_at_position()
     else {
       symbol internal_name = read_identifier(true /* required */);
       if (!internal_name.is_null()) {
-       symbol filename = get_long_name();
+       symbol filename = read_long_identifier();
        if (!mount_font(n, internal_name, filename)) {
          string msg;
          if (filename != 0 /* nullptr */)
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index c4284a658..568d82fca 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -128,7 +128,7 @@ extern token tok;           // the current token
 extern bool has_arg(bool /* want_peek */ = false);
 extern void skip_line();
 extern symbol read_identifier(bool /* required */ = false);
-extern symbol get_long_name(bool /* required */ = false);
+extern symbol read_long_identifier(bool /* required */ = false);
 extern void handle_initial_title();
 extern charinfo *read_character(); // TODO?: bool /* required */ = false
 extern char *read_rest_of_line_as_argument();

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

Reply via email to