groff-commit
[Top][All Lists]
Advanced

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

[groff] 09/27: [troff]: Boolify & rename check_font, check_style.


From: G. Branden Robinson
Subject: [groff] 09/27: [troff]: Boolify & rename check_font, check_style.
Date: Mon, 28 Aug 2023 15:54:46 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit ef01a9d58d61ace079296bb4b0d9a99cad15074d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Aug 27 11:45:13 2023 -0500

    [troff]: Boolify & rename check_font, check_style.
    
    [troff]: Trivially refactor; demote `int`-returning functions to
    Boolean-returning ones and rename.
      - check_font -> is_font_name
      - check_style -> is_abstract_style
    
    * src/roff/troff/node.h:
    * src/roff/troff/node.cpp: Do it.
    
    * src/roff/troff/env.cpp (is_family_valid):
    * src/roff/troff/input.cpp (do_if_request): Update call sites.
---
 ChangeLog                | 13 +++++++++++++
 src/roff/troff/env.cpp   |  2 +-
 src/roff/troff/input.cpp |  4 ++--
 src/roff/troff/node.cpp  |  8 +++++---
 src/roff/troff/node.h    |  4 ++--
 5 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 11c77ccb7..3a3cd14e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-08-27  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Trivially refactor; demote `int`-returning functions to
+       Boolean-returning ones and rename.
+       - check_font -> is_font_name
+       - check_style -> is_abstract_style
+
+       * src/roff/troff/node.h:
+       * src/roff/troff/node.cpp: Do it.
+
+       * src/roff/troff/env.cpp (is_family_valid):
+       * src/roff/troff/input.cpp (do_if_request): Update call sites.
+
 2023-08-27  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/preproc/eqn/main.cpp (main): Trivially refactor; demote
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index d3f9b4a8f..2f2e60bb4 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1268,7 +1268,7 @@ bool is_family_valid(const char *fam)
   std::vector<const char *>::iterator style;
   for (style = styles.begin(); style != styles.end(); style++)
 #endif
-    if (!check_font(fam, *style))
+    if (!is_font_name(fam, *style))
       return false;
   return true;
 }
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 571370faf..94ad67279 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5945,7 +5945,7 @@ int do_if_request()
       skip_alternative();
       return 0;
     }
-    result = check_font(curenv->get_family()->nm, nm);
+    result = is_font_name(curenv->get_family()->nm, nm);
   }
   else if (c == 'S') {
     tok.next();
@@ -5954,7 +5954,7 @@ int do_if_request()
       skip_alternative();
       return 0;
     }
-    result = check_style(nm);
+    result = is_abstract_style(nm);
   }
   else if (tok.is_space())
     result = 0;
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index f887429bc..74972eba0 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -5994,14 +5994,16 @@ bool mount_font(int n, symbol name, symbol 
external_name)
   return mount_font_no_translate(n, name, external_name);
 }
 
-int check_font(symbol fam, symbol name)
+// True for abstract styles and resolved font names.
+bool is_font_name(symbol fam, symbol name)
 {
-  if (check_style(name))
+  if (is_abstract_style(name))
     name = concat(fam, name);
   return mount_font_no_translate(0, name, name, true /* check only */);
 }
 
-int check_style(symbol s)
+// True for abstract styles.
+bool is_abstract_style(symbol s)
 {
   int i = symbol_fontno(s);
   return i < 0 ? 0 : font_table[i]->is_style();
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index b63f79cb3..6be250da5 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -613,8 +613,8 @@ inline hyphen_list::hyphen_list(unsigned char code, 
hyphen_list *p)
 
 extern void read_desc();
 extern bool mount_font(int, symbol, symbol = NULL_SYMBOL);
-extern int check_font(symbol, symbol);
-extern int check_style(symbol);
+extern bool is_font_name(symbol, symbol);
+extern bool is_abstract_style(symbol);
 extern bool mount_style(int, symbol);
 extern int is_good_fontno(int);
 extern int symbol_fontno(symbol);



reply via email to

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