gbranden pushed a commit to branch master
in repository groff.
commit ec173a3ca4dd2daf070afcd613ac712e504ae1b1
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Apr 13 09:44:08 2026 -0500
src/roff/troff/node.cpp: Refactor.
* src/roff/troff/node.cpp: Take one of
`assign_font_and_file_name_to_mounting_position()`'s jobs away from
it, awarding it instead to the only call site that wanted that job
done.
(assign_font_and_file_name_to_mounting_position): Drop `check_only`
parameter and dependent logic, and...
(is_font_available): ...open-code that logic here instead.
---
ChangeLog | 10 ++++++++++
src/roff/troff/node.cpp | 24 ++++++++++++------------
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5ce44a89f..35022101a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-04-13 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/node.cpp: Refactor. Take one of
+ `assign_font_and_file_name_to_mounting_position()`'s jobs away
+ from it, awarding it instead to the only call site that wanted
+ that job done.
+ (assign_font_and_file_name_to_mounting_position): Drop
+ `check_only` parameter and dependent logic, and...
+ (is_font_available): ...open-code that logic here instead.
+
2026-04-13 G. Branden Robinson <[email protected]>
[libgroff]: Trivially refactor. Rename library's `concat()`
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 94ca10915..24b3be6ad 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -6669,20 +6669,14 @@ font nonexistent_font = font("\0");
// Assign troff font identifier `name`, with font description file
// `filename`, to mounting position `n`. (The former two are often
// identical.) Return Boolean reporting success of this "mounting".
-//
-// If `check_only`, look up font identifier `name` in the existing
-// list of mounted fonts, and return Boolean indicating its presence.
-// TODO: We could use a separate function for "checking only".
static bool assign_font_and_file_name_to_mounting_position(
- symbol name, symbol filename, int n, bool check_only = false)
+ symbol name, symbol filename, int n)
{
assert(n >= 0);
font *fm = 0 /* nullptr */;
void *p = font_dictionary.lookup(filename);
if (0 /* nullptr */ == p) {
- fm = font::load_font(filename.contents(), check_only);
- if (check_only)
- return fm != 0 /* nullptr */;
+ fm = font::load_font(filename.contents());
if (0 /* nullptr */ == fm) {
(void) font_dictionary.lookup(filename, &nonexistent_font);
return false;
@@ -6693,8 +6687,6 @@ static bool
assign_font_and_file_name_to_mounting_position(
return false;
else
fm = static_cast<font *>(p);
- if (check_only)
- return true;
if (n >= font_table_size) {
if ((n - font_table_size) > 1000) {
error("requested font mounting position %1 too much larger than"
@@ -6754,8 +6746,16 @@ bool is_font_available(symbol fam, symbol name)
{
if (is_abstract_style(name))
name = catenate(fam, name); // Resolve the font name.
- return assign_font_and_file_name_to_mounting_position(name,
- name /* ignored */, 0 /* ignored */, true /* validate_only */);
+ font *fm = 0 /* nullptr */;
+ void *p = font_dictionary.lookup(name);
+ if (0 /* nullptr */ == p) {
+ // The font is not already mounted; could it be?
+ fm = font::load_font(name.contents(), true /* validate_only */);
+ return (fm != 0 /* nullptr */);
+ }
+ else if (&nonexistent_font == p)
+ return false;
+ return true;
}
bool mount_style(int n, symbol name)
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit