gbranden pushed a commit to branch master
in repository groff.

commit 7d166acf6c1a69147d79cf34bff11a754d273e33
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Apr 15 06:04:07 2026 -0500

    src/roff/troff/node.cpp: Refactor (2/3).
    
    ...some gro(h)t(ml)esquerie.
    
    * src/roff/troff/node.cpp (suppress_node::tprint): Refactor code
      populating "grohtml-info" output to access the contents of `psbb`
      request-populated registers `op{min,max}{x,y}` directly via their
      member functions instead of this file's `get_register()` function,
      which syntactically sugars that procedure.
---
 ChangeLog               | 10 ++++++++++
 src/roff/troff/node.cpp | 27 +++++++++++++--------------
 2 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3b51d9eaa..b8fefc38f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-04-15  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/node.cpp (suppress_node::tprint): Refactor code
+       populating "grohtml-info" output to access the contents of
+       `psbb` request-populated registers `op{min,max}{x,y}` directly
+       via their member functions instead of this file's
+       `get_register()` function, which syntactically sugars that
+       procedure.
+       (get_register): Delete now-unused function.
+
 2026-04-15  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/node.cpp (suppress_node::tprint): Refactor code
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 1fb701c90..06e09fb6a 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -4612,18 +4612,6 @@ int tag_node::ends_sentence()
   return 2;
 }
 
-// Get contents of register `p` as integer.
-// Used only by suppress_node::tprint().
-static int get_register(const char *p)
-{
-  assert(p != 0 /* nullptr */);
-  reg *r = static_cast<reg *>(register_dictionary.lookup(p));
-  assert(r != 0 /* nullptr */);
-  units value;
-  assert(r->get_value(&value));
-  return int(value);
-}
-
 // Get contents of register `p` as string.
 // Used only by suppress_node::tprint().
 static const char *get_string(const char *p)
@@ -4775,6 +4763,18 @@ void suppress_node::tprint(troff_output_file *out)
        //        topdiv->get_page_number(),
        //        suppression_starting_page_number);
        // `name` will contain a "%d" in which the image_no is placed.
+       units opminx, opminy, opmaxx, opmaxy;
+       // XXX: We ignore `get_value()`'s return value.  It's false if
+       // the register didn't already exist.  We assume that it does or
+       // this code won't work anyway.
+       (void) static_cast<reg *>(register_dictionary.lookup("opminx"))
+               ->get_value(&opminx);
+       (void) static_cast<reg *>(register_dictionary.lookup("opminy"))
+               ->get_value(&opminy);
+       (void) static_cast<reg *>(register_dictionary.lookup("opmaxx"))
+               ->get_value(&opmaxx);
+       (void) static_cast<reg *>(register_dictionary.lookup("opmaxy"))
+               ->get_value(&opmaxy);
        units page_width; // not counting the right margin
        if (ckd_add(&page_width, topdiv->get_page_offset().to_units(),
                    curenv->get_line_length().to_units()))
@@ -4785,8 +4785,7 @@ void suppress_node::tprint(troff_output_file *out)
                "grohtml-info:page %d  %d  %d  %d  %d  %d  %s  %d  %d"
                "  %s:%s\n",
                topdiv->get_page_number(),
-               get_register("opminx"), get_register("opminy"),
-               get_register("opmaxx"), get_register("opmaxy"),
+               opminx, opminy, opmaxx, opmaxy,
                page_width,
                name, hresolution, vresolution, get_string(".F"),
                get_string(".c"));

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

Reply via email to