gbranden pushed a commit to branch master
in repository groff.

commit bb07dbccf6ca69597a564409b8237ae53d99e00b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 22 20:04:21 2026 -0600

    [troff]: `pfp` request accepts arguments.
    
    * src/roff/troff/node.cpp (dump_font_mounting_position): New function
      dumps to standard error information, if any, about font mounted at
      position given in argument.
    
      (print_font_mounting_position_request): Accept arguments; interpret
      each as a font mounting position, and dump its info if it is valid and
      in range.  Migrate existing report of all occupied mounting positions
      to use new function.
    
    Begins fixing <https://savannah.gnu.org/bugs/?68904>.
---
 ChangeLog               | 11 +++++++++++
 src/roff/troff/node.cpp | 50 ++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 48 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80733db8d..10e8fd33c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-11-22  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/node.cpp (dump_font_mounting_position): New
+       function dumps to standard error information, if any, about font
+       mounted at position given in argument.
+
+       (print_font_mounting_position_request): Accept arguments;
+       interpret each as a font mounting position, and dump its info if
+       it is valid and in range.  Migrate existing report of all
+       occupied mounting positions to use new function.
+
 2026-11-22  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/node.cpp: Trivially refactor.  Rename
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 74ec4b592..971a6931a 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6742,22 +6742,46 @@ static bool 
assign_font_and_file_name_to_mounting_position(
   return true;
 }
 
+static void dump_font_mounting_position(int pos)
+{
+  assert(pos >= 0);
+  if (pos < 0) // NDEBUG
+    return;
+  if (pos > mounted_font_size)
+    return;
+  font_info *fi = mounted_font[pos];
+  if (0 /* nullptr */ == fi) // No font mounted here.
+    return;
+  errprint("%1\t%2", pos, fi->get_name().contents());
+  font *f = mounted_font[pos]->get_font();
+  if (f != 0 /* nullptr */) { // It's not an abstract style.
+    errprint("\t%1", f->get_filename());
+    if (f->get_internal_name() != 0 /* nullptr */)
+      errprint("\t%1", f->get_internal_name());
+  }
+  errprint("\n");
+}
+
 static void print_font_mounting_position_request() // .pfp
 {
-  for (int i = 0; i < mounted_font_size; i++) {
-    font_info *fi = mounted_font[i];
-    if (0 /* nullptr */ == fi) // No font mounted here.
-      continue;
-    errprint("%1\t%2", i, fi->get_name().contents());
-    font *f = mounted_font[i]->get_font();
-    if (f != 0 /* nullptr */) { // It's not an abstract style.
-      errprint("\t%1", f->get_filename());
-      if (f->get_internal_name() != 0 /* nullptr */)
-       errprint("\t%1", f->get_internal_name());
-    }
-    errprint("\n");
-    fflush(stderr);
+  int pos; // mounting position
+  if (has_arg()) {
+    do {
+      if (!read_integer(&pos)) {
+       skip_rest_of_argument();
+       continue;
+      }
+      if (pos < 0) {
+       error("cannot report negative font mounting position %1", pos);
+       continue;
+      }
+      dump_font_mounting_position(pos);
+    } while (has_arg());
   }
+  else
+    for (pos = 0; pos < mounted_font_size; pos++)
+      dump_font_mounting_position(pos);
+  fflush(stderr);
   skip_line();
 }
 

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

Reply via email to