groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 07/25: [troff]: Trivially refactor.


From: G. Branden Robinson
Subject: [groff] 07/25: [troff]: Trivially refactor.
Date: Tue, 29 Oct 2024 02:26:03 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 9eaf6f0448d3067b147864dd80c59bb237eef265
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Oct 23 15:46:29 2024 -0500

    [troff]: Trivially refactor.
    
    ...renaming the font size "table" to the font size "list"; it's not a
    two-dimensional structure.
    
    * src/roff/troff/env.h (class font_size): Rename member variable
      `size_table` to `size_list`.  Rename member functions
      `init_size_table()` and `dump_size_table()` to `init_size_list()` and
      `dump_size_list()`.
    
    * src/roff/troff/env.cpp: Update definition, call, and
      derefernce sites in the global scope and...
      (font_size::init_size_list, font_size::dump_size_list):
      (font_size::font_size, override_sizes, environment::print_env):
      ...here.
    
    * src/roff/troff/input.cpp (main): Update call site (setting up size
      list for font used in default environment at startup).
    
    * src/roff/troff/node.h: Update external declaration.
---
 ChangeLog                | 18 ++++++++++++++++++
 src/roff/troff/env.cpp   | 36 ++++++++++++++++++------------------
 src/roff/troff/env.h     |  6 +++---
 src/roff/troff/input.cpp |  2 +-
 src/roff/troff/node.h    |  2 +-
 5 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eaf95b46d..22058d847 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2024-10-23  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Trivially refactor, renaming the font size "table" to
+       the font size "list"; it's not a two-dimensional structure.
+
+       * src/roff/troff/env.h (class font_size): Rename member variable
+       `size_table` to `size_list`.  Rename member functions
+       `init_size_table()` and `dump_size_table()` to
+       `init_size_list()` and `dump_size_list()`.
+       * src/roff/troff/env.cpp: Update definition, call, and
+       derefernce sites in the global scope and...
+       (font_size::init_size_list, font_size::dump_size_list):
+       (font_size::font_size, override_sizes, environment::print_env):
+       ...here.
+       * src/roff/troff/input.cpp (main): Update call site (setting up
+       size list for font used in default environment at startup).
+       * src/roff/troff/node.h: Update external declaration.
+
 2024-10-23  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/sv.tmac: Spell string translations using groff special
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index a087bc601..cd6fea8a7 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -222,7 +222,7 @@ void widow_control_request()
 
 /* font_size functions */
 
-size_range *font_size::size_table = 0 /* nullptr */;
+size_range *font_size::size_list = 0 /* nullptr */;
 int font_size::nranges = 0;
 
 extern "C" {
@@ -234,31 +234,31 @@ int compare_ranges(const void *p1, const void *p2)
 
 }
 
-void font_size::init_size_table(int *sizes)
+void font_size::init_size_list(int *sizes)
 {
   nranges = 0;
   while (sizes[nranges * 2] != 0)
     nranges++;
   assert(nranges > 0);
-  size_table = new size_range[nranges];
+  size_list = new size_range[nranges];
   for (int i = 0; i < nranges; i++) {
-    size_table[i].min = sizes[i * 2];
-    size_table[i].max = sizes[i * 2 + 1];
+    size_list[i].min = sizes[i * 2];
+    size_list[i].max = sizes[i * 2 + 1];
   }
-  qsort(size_table, nranges, sizeof(size_range), compare_ranges);
+  qsort(size_list, nranges, sizeof(size_range), compare_ranges);
 }
 
-void font_size::dump_size_table()
+void font_size::dump_size_list()
 {
   int lo, hi;
-  errprint("  valid type size table for selected font: ");
+  errprint("  valid type size list for selected font: ");
   if (nranges == 0)
     errprint(" empty!");
   else {
     bool need_comma = false;
     for (int i = 0; i < nranges; i++) {
-      lo = size_table[i].min;
-      hi = size_table[i].max;
+      lo = size_list[i].min;
+      hi = size_list[i].max;
       if (need_comma)
        errprint(", ");
       if (lo == hi)
@@ -275,19 +275,19 @@ void font_size::dump_size_table()
 font_size::font_size(int sp)
 {
   for (int i = 0; i < nranges; i++) {
-    if (sp < size_table[i].min) {
-      if (i > 0 && size_table[i].min - sp >= sp - size_table[i - 1].max)
-       p = size_table[i - 1].max;
+    if (sp < size_list[i].min) {
+      if (i > 0 && size_list[i].min - sp >= sp - size_list[i - 1].max)
+       p = size_list[i - 1].max;
       else
-       p = size_table[i].min;
+       p = size_list[i].min;
       return;
     }
-    if (sp <= size_table[i].max) {
+    if (sp <= size_list[i].max) {
       p = sp;
       return;
     }
   }
-  p = size_table[nranges - 1].max;
+  p = size_list[nranges - 1].max;
 }
 
 int font_size::to_units()
@@ -1403,7 +1403,7 @@ void override_sizes()
     sizes[i++] = upper;
     p = strtok(0, " \t");
   }
-  font_size::init_size_table(sizes);
+  font_size::init_size_list(sizes);
 }
 
 void space_size()
@@ -3479,7 +3479,7 @@ void environment::print_env()
     errprint("  previous requested type size: %1s\n",
             prev_requested_size);
     errprint("  requested type size: %1s\n", requested_size);
-    font_size::dump_size_table();
+    font_size::dump_size_list();
   }
   errprint("  previous font selection: %1 ('%2')\n", prev_fontno,
           get_font_name(prev_fontno, this).contents());
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 3d53f13c2..6b4ec03f9 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -24,7 +24,7 @@ struct size_range {
 };
 
 class font_size {
-  static size_range *size_table;
+  static size_range *size_list;
   static int nranges;
   int p;
 public:
@@ -35,8 +35,8 @@ public:
   int to_units();
   int operator==(font_size);
   int operator!=(font_size);
-  static void init_size_table(int *sizes);
-  static void dump_size_table();
+  static void init_size_list(int *sizes);
+  static void dump_size_list();
 };
 
 inline font_size::font_size() : p(0)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 3732f1b83..ddb5db681 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -9049,7 +9049,7 @@ int main(int argc, char **argv)
   if (!have_explicit_default_family && (font::family != 0 /* nullptr */)
       && *font::family != '\0')
     default_family = symbol(font::family);
-  font_size::init_size_table(font::sizes);
+  font_size::init_size_list(font::sizes);
   int i;
   int j = 1;
   if (font::style_table)
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 39ea004a9..4e1b15ce2 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -657,7 +657,7 @@ extern bool mount_style(int, symbol);
 extern int is_good_fontno(int);
 extern int symbol_fontno(symbol);
 extern int next_available_font_position();
-extern void init_size_table(int *);
+extern void init_size_list(int *);
 extern int get_underline_fontno();
 
 class output_file {



reply via email to

[Prev in Thread] Current Thread [Next in Thread]