gbranden pushed a commit to branch master
in repository groff.

commit f81fc4771b7f04dad4df4ea382bcb0e5063f0948
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Apr 13 10:13:44 2026 -0500

    [troff]: Trivially refactor (3/10).
    
    Rename function to better align with terminology used in our
    documentation.
    
    * src/roff/troff/node.h: Rename declaration of `mount_font()` to
      `mount_font_at_position()`.  Also resequence arguments to follow the
      order implies by the English words in the function name.  (Compare
      fprintf(3) and contrast fputs(3).)
    
    * src/roff/troff/node.cpp (mount_font): Rename this...
      (mount_font_at_position): ...to this.  Resequence arguments.
    
    * src/roff/troff/env.cpp (environment::set_font):
    * src/roff/troff/input.cpp (main):
    * src/roff/troff/node.cpp (mount_font_at_position_request)
      (read_font_identifier, zoom_font_request): Update call sites.
---
 ChangeLog                | 11 +++++++++++
 src/roff/troff/env.cpp   |  2 +-
 src/roff/troff/input.cpp |  2 +-
 src/roff/troff/node.cpp  | 30 +++++++++++++++---------------
 src/roff/troff/node.h    |  4 ++--
 5 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 99a4227b4..0d5aa8d56 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,17 @@
        (font_family::resolve, read_font_identifier, zoom_font_request)
        (next_available_font_position_reg): Update call sites.
 
+       * src/roff/troff/node.h: Rename declaration of
+       `mount_font()` to `mount_font_at_position()`.  Also resequence
+       arguments to follow the order implies by the English words in
+       the function name.  (Compare fprintf(3) and contrast fputs(3).)
+       * src/roff/troff/node.cpp (mount_font): Rename this...
+       (mount_font_at_position): ...to this.  Resequence arguments.
+       * src/roff/troff/env.cpp (environment::set_font):
+       * src/roff/troff/input.cpp (main):
+       * src/roff/troff/node.cpp (mount_font_at_position_request)
+       (read_font_identifier, zoom_font_request): Update call sites.
+
 2026-04-13  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/node.cpp: Refactor.  Take one of
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 351aec75c..6d0fa03da 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -645,7 +645,7 @@ bool environment::set_font(symbol nm)
     int n = mounting_position_of_font(nm);
     if (n < 0) {
       n = next_available_font_mounting_position();
-      if (!mount_font(n, nm))
+      if (!mount_font_at_position(nm, n))
        return false;
     }
     if (family->resolve(n) == FONT_NOT_MOUNTED)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 7aa5391c0..d4f6fd9a1 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -10144,7 +10144,7 @@ int main(int argc, char **argv)
     // In the DESC file, a font name of 0 (zero) means "leave this
     // position empty".
     if (strcmp(font::font_name_table[i], "0") != 0)
-      if (!mount_font(j, symbol(font::font_name_table[i])))
+      if (!mount_font_at_position(symbol(font::font_name_table[i]), j))
        warning(WARN_FONT, "cannot mount font '%1' directed by 'DESC'"
                " file for device '%2'", font::font_name_table[i],
                device);
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index ff2f9f2fc..709538fa0 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6722,7 +6722,7 @@ static void print_font_mounting_position_request() // .pfp
   skip_line();
 }
 
-bool mount_font(int n, symbol name, symbol external_name)
+bool mount_font_at_position(symbol name, int n, symbol external_name)
 {
   assert(n >= 0);
   name = get_font_translation(name);
@@ -6841,7 +6841,7 @@ static void mount_font_at_position_request() // .fp
        = read_identifier(true /* want_diagnostic */);
       if (!internal_name.is_null()) {
        symbol filename = read_long_identifier();
-       if (!mount_font(n, internal_name, filename)) {
+       if (!mount_font_at_position(internal_name, n, filename)) {
          string msg;
          if (filename != 0 /* nullptr */)
            msg += string(" from file '") + filename.contents()
@@ -7012,7 +7012,7 @@ static bool read_font_identifier(font_lookup_info *finfo)
       n = mounting_position_of_font(s);
       if (n < 0) {
        n = next_available_font_mounting_position();
-       if (mount_font(n, s))
+       if (mount_font_at_position(s, n))
          finfo->position = n;
       }
       finfo->position = curenv->get_family()->resolve(n);
@@ -7183,24 +7183,24 @@ static void zoom_font_request() // .fzoom
     return;
   }
   int fpos = next_available_font_mounting_position();
-  if (!(mount_font(fpos, font_name))) {
+  if (!(mount_font_at_position(font_name, fpos))) {
     error("cannot mount font '%1' to set a zoom factor for it",
          font_name.contents());
     skip_line();
     return;
   }
 #if 0
-  // This would be a good diagnostic to have, but mount_font() is too
-  // formally complex to make it easy.  Instead it will fail in the
-  // above test on a font named "R", for instance, when that is
-  // literally true but might not help users who don't understand that
-  // "R", "I", "B", and "BI" are (by default) abstract styles, not fonts
-  // in the GNU troff sense.  It is a shame that a lot of our validation
-  // functions are willing only to handle arguments that they eat from
-  // the input stream (i.e., you can't pass them information you
-  // obtained elsewhere).  That design also forces us to validate
-  // request arguments in the order they appear in the input, and seems
-  // unnecessarily inflexible to me.  --GBR
+  // This would be a good diagnostic to have, but
+  // mount_font_at_position() is too formally complex to make it easy.
+  // Instead it will fail in the above test on a font named "R", for
+  // instance, when that is literally true but might not help users who
+  // don't understand that "R", "I", "B", and "BI" are (by default)
+  // abstract styles, not fonts in the GNU troff sense.  It is a shame
+  // that a lot of our validation functions are willing only to handle
+  // arguments that they eat from the input stream (i.e., you can't pass
+  // them information you obtained elsewhere).  That design also forces
+  // us to validate request arguments in the order they appear in the
+  // input, and seems unnecessarily inflexible to me.  --GBR
   if (font_table[fpos]->is_style()) {
     warning(WARN_FONT, "ignoring request to set font zoom factor on an"
            " abstract style");
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 924112723..6aa47ef68 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -702,8 +702,8 @@ inline hyphen_list::hyphen_list(unsigned char code, 
hyphen_list *p)
 }
 
 extern void read_desc();
-extern bool mount_font(int, symbol,
-                      symbol /* external_name */ = NULL_SYMBOL);
+extern bool mount_font_at_position(symbol, int,
+    symbol /* external_name */ = NULL_SYMBOL);
 extern bool is_font_available(symbol /* family */, symbol /* name */);
 extern bool is_abstract_style(symbol);
 extern bool mount_style(int, symbol);

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

Reply via email to