gbranden pushed a commit to branch master
in repository groff.
commit 5edf625818c65da5e17f861f5e0cd55b515c9234
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Nov 15 05:49:54 2025 -0600
[troff]: Slightly refactor.
Boolify `charinfo` member functions.
* src/roff/troff/charinfo.h (class charinfo): Demote integer arguments
to `set_translation()` and `set_special_translation()` from `int` to
`bool`.
(charinfo::get_special_translation): Rename argument from
`for_transparent_throughput` to `transparently`.
* src/roff/troff/input.cpp (charinfo::set_translation): Demote argument
types as above, and rename from the cryptic `tt` and `ti` to
`transparently` and `as_input`, respectively.
(charinfo::set_special_translation): Demote argument types as above.
Rename `c` to `cc` ("character code", as abbreivated elsewhere in this
file), and `tt` to `transparently`.
(do_translate): Demote integer arguments `translate_transparent` and
`translate_input` from `int` to `bool`, and rename them to
`transparently` and `as_input`, respectively, to obviously correspond
with `charinfo` class member functions to which they are passed.
(transparent_translate, translate, translate_no_transparent)
(transparent_input): Update call sites to use Boolean literals and
annotate argument correspondence.
---
ChangeLog | 24 ++++++++++++++++++++++++
src/roff/troff/charinfo.h | 9 +++++----
src/roff/troff/input.cpp | 39 +++++++++++++++++++--------------------
3 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c7b2e0e19..c43b31fa1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2025-11-15 G. Branden Robinson <[email protected]>
+
+ [troff]: Slightly refactor; boolify `charinfo` member functions.
+
+ * src/roff/troff/charinfo.h (class charinfo): Demote integer
+ arguments to `set_translation()` and `set_special_translation()`
+ from `int` to `bool`.
+ (charinfo::get_special_translation): Rename argument from
+ `for_transparent_throughput` to `transparently`.
+ * src/roff/troff/input.cpp (charinfo::set_translation): Demote
+ argument types as above, and rename from the cryptic `tt` and
+ `ti` to `transparently` and `as_input`, respectively.
+ (charinfo::set_special_translation): Demote argument types as
+ above. Rename `c` to `cc` ("character code", as abbreivated
+ elsewhere in this file), and `tt` to `transparently`.
+ (do_translate): Demote integer arguments `translate_transparent`
+ and `translate_input` from `int` to `bool`, and rename them to
+ `transparently` and `as_input`, respectively, to obviously
+ correspond with `charinfo` class member functions to which they
+ are passed.
+ (transparent_translate, translate, translate_no_transparent)
+ (transparent_input): Update call sites to use Boolean literals
+ and annotate argument correspondence.
+
2025-11-15 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (charinfo::set_hyphenation_code): Fix
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h
index 797a7f5f2..92c79a202 100644
--- a/src/roff/troff/charinfo.h
+++ b/src/roff/troff/charinfo.h
@@ -95,10 +95,11 @@ public:
void make_translatable_as_input();
bool is_translatable_as_input();
charinfo *get_translation(bool = false);
- void set_translation(charinfo *, int, int);
+ void set_translation(charinfo *, bool /* transparently */,
+ bool /* as_input */);
void get_flags();
void set_flags(unsigned int);
- void set_special_translation(int, int);
+ void set_special_translation(int, bool /* transparently */);
int get_special_translation(bool = false);
macro *set_macro(macro *);
macro *set_macro(macro *, char_mode);
@@ -256,9 +257,9 @@ inline bool charinfo::is_translatable_as_input()
return translatable_as_input;
}
-inline int charinfo::get_special_translation(bool for_transparent_throughput)
+inline int charinfo::get_special_translation(bool transparently)
{
- return (for_transparent_throughput && !is_transparently_translatable
+ return (transparently && !is_transparently_translatable
? int(TRANSLATE_NONE)
: special_translation);
}
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ee16beee3..f7b8402e0 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3225,7 +3225,7 @@ static int transparent_translate(int cc)
{
if (!is_invalid_input_char(cc)) {
charinfo *ci = charset_table[cc];
- switch (ci->get_special_translation(1)) {
+ switch (ci->get_special_translation(true /* transparently */)) {
case charinfo::TRANSLATE_SPACE:
return ' ';
case charinfo::TRANSLATE_STRETCHABLE_SPACE:
@@ -8293,7 +8293,7 @@ static void init_hpf_code_table()
hpf_code_table[i] = cmlower(i);
}
-static void do_translate(int translate_transparent, int translate_input)
+static void do_translate(bool transparently, bool as_input)
{
tok.skip();
while (!tok.is_newline() && !tok.is_eof()) {
@@ -8313,31 +8313,29 @@ static void do_translate(int translate_transparent, int
translate_input)
tok.next();
if (tok.is_newline() || tok.is_eof()) {
ci1->set_special_translation(charinfo::TRANSLATE_SPACE,
- translate_transparent);
+ transparently);
break;
}
if (tok.is_space())
ci1->set_special_translation(charinfo::TRANSLATE_SPACE,
- translate_transparent);
+ transparently);
else if (tok.is_stretchable_space())
ci1->set_special_translation(charinfo::TRANSLATE_STRETCHABLE_SPACE,
- translate_transparent);
+ transparently);
else if (tok.is_dummy())
ci1->set_special_translation(charinfo::TRANSLATE_DUMMY,
- translate_transparent);
+ transparently);
else if (tok.is_hyphen_indicator())
ci1->set_special_translation(charinfo::TRANSLATE_HYPHEN_INDICATOR,
- translate_transparent);
+ transparently);
else {
charinfo *ci2 = tok.get_char(true /* required */);
if (0 /* nullptr */ == ci2)
break;
if (ci1 == ci2)
- ci1->set_translation(0 /* nullptr */, translate_transparent,
- translate_input);
+ ci1->set_translation(0 /* nullptr */, transparently, as_input);
else
- ci1->set_translation(ci2, translate_transparent,
- translate_input);
+ ci1->set_translation(ci2, transparently, as_input);
}
tok.next();
}
@@ -8352,7 +8350,7 @@ void translate()
skip_line();
return;
}
- do_translate(1 /* transparent */, 0 /* input */);
+ do_translate(true /* transparently */, false /* as_input */);
}
void translate_no_transparent()
@@ -8363,7 +8361,7 @@ void translate_no_transparent()
skip_line();
return;
}
- do_translate(0 /* transparent */, 0 /* input */);
+ do_translate(false /* transparently */, false /* as_input */);
}
void translate_input()
@@ -8374,7 +8372,7 @@ void translate_input()
skip_line();
return;
}
- do_translate(1 /* transparent */, 1 /* input */);
+ do_translate(true /* transparently */, true /* as_input */);
}
static void set_character_flags_request()
@@ -10554,10 +10552,11 @@ void charinfo::set_hyphenation_code(unsigned char c)
hyphenation_code = c;
}
-void charinfo::set_translation(charinfo *ci, int tt, int ti)
+void charinfo::set_translation(charinfo *ci, bool transparently,
+ bool as_input)
{
translation = ci;
- if ((ci != 0 /* nullptr */) && ti) {
+ if ((ci != 0 /* nullptr */) && as_input) {
if (hyphenation_code != 0U)
ci->set_hyphenation_code(hyphenation_code);
if (asciify_code != 0U)
@@ -10567,7 +10566,7 @@ void charinfo::set_translation(charinfo *ci, int tt,
int ti)
ci->make_translatable_as_input();
}
special_translation = TRANSLATE_NONE;
- is_transparently_translatable = tt;
+ is_transparently_translatable = transparently;
}
// Recompute flags for all entries in the charinfo dictionary.
@@ -10607,11 +10606,11 @@ void charinfo::get_flags()
}
}
-void charinfo::set_special_translation(int c, int tt)
+void charinfo::set_special_translation(int cc, bool transparently)
{
- special_translation = c;
+ special_translation = cc;
translation = 0 /* nullptr */;
- is_transparently_translatable = tt;
+ is_transparently_translatable = transparently;
}
void charinfo::set_ascii_code(unsigned char c)
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit