gbranden pushed a commit to branch master
in repository groff.
commit d2e2ca1a3b28f28ab8992e3cdec33c88cb10339a
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 24 18:49:46 2025 -0600
[troff]: Trivially refactor.
Rename `token` class's member function `is_character()` to
`is_any_character()` to try and get across the idea that it's true for
_any_ sort of character: ordinary {`A`}, special {`\[em]`, `\C'em'`}, or
indexed {`\N'45'`}.
* src/roff/troff/token.h (class token): Update declaration.
(token::is_any_character): Update (inline) definition.
* src/roff/troff/input.cpp (print_character_request)
(remove_character):
* src/roff/troff/node.cpp (embolden_font): Update call sites.
Also annotate possible future direction.
---
ChangeLog | 14 ++++++++++++++
src/roff/troff/input.cpp | 4 ++--
src/roff/troff/node.cpp | 8 ++++++--
src/roff/troff/token.h | 5 +++--
4 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c0e449693..3d5ba1ab5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2025-11-24 G. Branden Robinson <[email protected]>
+
+ [troff]: Trivially refactor. Rename `token` class's member
+ function `is_character()` to `is_any_character()` to try and get
+ across the idea that it's true for _any_ sort of character:
+ ordinary {`A`}, special {`\[em]`, `\C'em'`}, or indexed
+ {`\N'45'`}.
+
+ * src/roff/troff/token.h (class token): Update declaration.
+ (token::is_any_character): Update (inline) definition.
+ * src/roff/troff/input.cpp (print_character_request)
+ (remove_character):
+ * src/roff/troff/node.cpp (embolden_font): Update call sites.
+
2025-11-24 G. Branden Robinson <[email protected]>
* src/roff/troff/reg.cpp (dump_register): Add assertion.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index a34066fe0..89fa2354b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5085,7 +5085,7 @@ static void print_character_request()
charinfo *ci;
do {
tok.skip_spaces();
- if (!tok.is_character()) {
+ if (!tok.is_any_character()) {
error("character report request expects characters or character"
" classes as arguments; got %1", tok.description());
break;
@@ -5114,7 +5114,7 @@ static void remove_character()
}
while (!tok.is_newline() && !tok.is_eof()) {
if (!tok.is_space() && !tok.is_tab()) {
- if (tok.is_character()) {
+ if (tok.is_any_character()) {
charinfo *ci = tok.get_charinfo(true /* required */,
true /* suppress creation */);
if (0 /* nullptr */ == ci)
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 1370d7473..ca8212a50 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -7283,7 +7283,10 @@ static void embolden_font()
skip_line();
return;
}
- if ((!tok.is_character())
+ // XXX: Here's where `is_ordinary_character()` would be useful.
+ // (TOKEN_CHAR == type) means the same thing, but this file doesn't
+ // root around in token::token_type...
+ if ((!tok.is_any_character())
|| tok.is_special_character()
|| tok.is_indexed_character()) {
error("emboldening request expects font name or mounting position"
@@ -7314,7 +7317,8 @@ static void embolden_font()
}
int n = finfo.position;
if (has_arg()) {
- if ((!tok.is_character())
+ // XXX: Here's another useful `is_ordinary_character()` spot.
+ if ((!tok.is_any_character())
|| tok.is_special_character()
|| tok.is_indexed_character()) {
error("emboldening request expects font name or emboldening"
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index f541c1b59..5f1b37a53 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -90,7 +90,8 @@ public:
bool is_unstretchable_space();
bool is_horizontal_space();
bool is_white_space();
- bool is_character();
+ bool is_any_character();
+ // XXX: Do we need a `is_ordinary_character()`?
bool is_special_character();
bool is_indexed_character();
bool is_newline();
@@ -213,7 +214,7 @@ inline unsigned char token::ch()
return type == TOKEN_CHAR ? c : '\0';
}
-inline bool token::is_character()
+inline bool token::is_any_character()
{
return (TOKEN_CHAR == type) || (TOKEN_SPECIAL_CHAR == type)
|| (TOKEN_INDEXED_CHAR == type);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit