gbranden pushed a commit to branch master
in repository groff.
commit 992b180efe094f815e96cdc3fe68933108358f4e
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Apr 20 16:11:04 2025 -0500
[troff]: Trivially refactor.
Rename `font_family::make_definite()` to `font_family::resolve()`, to
better align internal naming practices with our documentation.
* src/roff/troff/node.h (class font_family): Do it.
* src/roff/troff/node.cpp (font_family::make_definite): Rename this...
(font_family::resolve): ...to this.
* src/roff/troff/env.cpp (environment::set_font)
(environment::set_family,environment::environment):
* src/roff/troff/node.h (env_definite_font, env_get_zoom, has_font):
Update call sites.
---
ChangeLog | 16 ++++++++++++++++
src/roff/troff/env.cpp | 10 +++++-----
src/roff/troff/node.cpp | 11 +++++------
src/roff/troff/node.h | 2 +-
4 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 31d346b82..88c4e9718 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2025-04-20 G. Branden Robinson <[email protected]>
+
+ [troff]: Trivially refactor. Rename
+ `font_family::make_definite()` to `font_family::resolve()`, to
+ better align internal naming practices with our documentation.
+
+ * src/roff/troff/node.h (class font_family): Do it.
+ * src/roff/troff/node.cpp (font_family::make_definite): Rename
+ this...
+ (font_family::resolve): ...to this.
+
+ * src/roff/troff/env.cpp (environment::set_font)
+ (environment::set_family,environment::environment):
+ * src/roff/troff/node.h (env_definite_font, env_get_zoom)
+ (has_font): Update call sites.
+
2025-04-20 G. Branden Robinson <[email protected]>
[troff]: Fix code style nits.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index ee3cf9df2..4786579a0 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -586,7 +586,7 @@ bool environment::set_font(symbol nm)
if (is_device_ps_or_pdf)
warn_if_font_name_deprecated(nm);
if (nm == symbol("P") || nm.is_empty()) {
- if (family->make_definite(prev_fontno) < 0)
+ if (family->resolve(prev_fontno) < 0)
return false;
int tem = fontno;
fontno = prev_fontno;
@@ -600,7 +600,7 @@ bool environment::set_font(symbol nm)
if (!mount_font(n, nm))
return false;
}
- if (family->make_definite(n) < 0)
+ if (family->resolve(n) < 0)
return false;
fontno = n;
}
@@ -633,7 +633,7 @@ void environment::set_family(symbol fam)
if (line_interrupted)
return;
if (fam.is_null() || fam.is_empty()) {
- int previous_mounting_position = prev_family->make_definite(fontno);
+ int previous_mounting_position = prev_family->resolve(fontno);
assert(previous_mounting_position >= 0);
if (previous_mounting_position < 0)
return;
@@ -650,7 +650,7 @@ void environment::set_family(symbol fam)
(0 != "font family dictionary lookup"));
if (0 /* nullptr */ == f)
return;
- if (f->make_definite(fontno) < 0) {
+ if (f->resolve(fontno) < 0) {
error("no font family named '%1' exists", fam.contents());
return;
}
@@ -816,7 +816,7 @@ environment::environment(symbol nm)
prev_fontno = fontno = 1;
if (!is_good_fontno(1))
fatal("font mounted at position 1 is not valid");
- if (family->make_definite(1) < 0)
+ if (family->resolve(1) < 0)
fatal("invalid default font family '%1'",
default_family.contents());
prev_fontno = fontno;
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 20a855b26..d8a94e12e 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -231,7 +231,7 @@ public:
inline int env_definite_font(environment *env)
{
- return env->get_family()->make_definite(env->get_font());
+ return env->get_family()->resolve(env->get_font());
}
/* font_info functions */
@@ -285,7 +285,7 @@ tfont *make_tfont(tfont_spec &spec)
int env_get_zoom(environment *env)
{
- int fontno = env->get_family()->make_definite(env->get_font());
+ int fontno = env->get_family()->resolve(env->get_font());
return font_table[fontno]->get_zoom();
}
@@ -6610,7 +6610,6 @@ font_family::~font_family()
// usable by the output driver. (Positions 1 through 4 are typically
// allocated to styles, and are not usable thus.) A return value of
// `-1` indicates failure.
-// TODO: Rename this to ::resolve() to align with documentation.
// TODO: Make a `const int FONT_NOT_MOUNTED = -1;`, and use that in
// callers (here and in "env.cpp"). Aping libc-style, `errno`-using
// functions conceals more than it reveals here since we have no analog
@@ -6618,7 +6617,7 @@ font_family::~font_family()
// and concurrency-friendly as a global lock. Option types,
// error-storing function parameters, and exceptions are all better
// solutions.)
-int font_family::make_definite(int mounting_position)
+int font_family::resolve(int mounting_position)
{
assert(mounting_position >= 0);
int pos = mounting_position;
@@ -6743,7 +6742,7 @@ static bool has_font(font_lookup_info *finfo)
if (mount_font(n, s))
finfo->position = n;
}
- finfo->position = curenv->get_family()->make_definite(n);
+ finfo->position = curenv->get_family()->resolve(n);
}
}
else if (get_integer(&n)) {
@@ -6751,7 +6750,7 @@ static bool has_font(font_lookup_info *finfo)
if (!((n < 0)
|| (n >= font_table_size)
|| (0 /* nullptr */ == font_table[n])))
- finfo->position = curenv->get_family()->make_definite(n);
+ finfo->position = curenv->get_family()->resolve(n);
}
return (finfo->position != -1);
}
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index cbd04c464..92c319986 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -732,7 +732,7 @@ public:
const symbol nm;
font_family(symbol);
~font_family();
- int make_definite(int);
+ int resolve(int);
static void invalidate_fontno(int);
};
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit