gbranden pushed a commit to branch master
in repository groff.
commit cfd134fe50644f4aff41cbd37ebe8fa51689484d
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Nov 27 00:41:53 2025 -0600
[troff]: Modestly refactor (6/8).
* src/roff/troff/input.cpp (read_size):
Construct integer from character literal.
* src/roff/troff/input.cpp (read_size): Use local variables to avoid
repeated member function calls. (Presumably a smart optimizer would
do the equivalent on its own, but this change also makes a lengthy
compound conditional expression shorter.)
---
ChangeLog | 7 ++++++-
src/roff/troff/input.cpp | 9 ++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5dd452f2e..aae4582f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,7 +13,8 @@
* src/roff/troff/env.cpp (configure_tab_stops_request):
* src/roff/troff/number.cpp (get_incr_number)
(is_valid_expression, is_valid_term):
- * src/roff/troff/input.cpp (get_line_arg):
+ * src/roff/troff/input.cpp (get_line_arg)
+ (read_size):
Construct integer from character literal.
* src/roff/troff/env.cpp (adjust):
* src/roff/troff/reg.cpp (assign_register_format_request):
@@ -22,6 +23,10 @@
`char`, type.
* src/roff/troff/env.cpp: Retype global `TAB_REPEAT_CHAR` from
{`const`} `char` to `unsigned char`.
+ * src/roff/troff/input.cpp (read_size): Use local variables to
+ avoid repeated member function calls. (Presumably a smart
+ optimizer would do the equivalent on its own, but this change
+ also makes a lengthy compound conditional expression shorter.)
2025-11-27 G. Branden Robinson <[email protected]>
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index abafce8d1..82c8e617e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -6103,8 +6103,11 @@ static bool read_size(int *x) // \s
}
if (!read_measurement(&val, 'z'))
return false;
- if (!((start.ch() == '[') && (tok.ch() == ']')) && (start != tok)) {
- if (start.ch() == '[')
+ // safely compares to char literals; TODO: grochar
+ int s = start.ch();
+ int t = tok.ch();
+ if (!((s == int('[')) && (t == int(']'))) && (start != tok)) {
+ if (s == int('['))
error("missing ']' in type size escape sequence");
else
error("missing closing delimiter in type size escape sequence");
@@ -6630,7 +6633,7 @@ static node *do_device_extension() // \X
if (tok == start_token
&& (want_att_compat || input_stack::get_level() == start_level))
break;
- unsigned char c;
+ unsigned char c; // TODO: grochar
if (tok.is_space())
c = ' ';
// TODO: Stop silently ignoring these when we have a string
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit