gbranden pushed a commit to branch master
in repository groff.
commit 9c3cccf4346f1b517d078d826132ba9966fa9fcb
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 30 05:53:29 2025 -0600
src/roff/troff/input.cpp: Trivially refactor.
* src/roff/troff/input.cpp: Rename function `read_delimited_number()` to
`read_delimited_measurement()` to reinforce the fact that it reads a
measurement (which is, in turn, numeric expression potentially
including operators).
(read_delimited_number): Rename (overloaded) declarations and
definitions from these...
(read_delimited_measurement): ...to these.
(token::next): Update call sites.
Also annotate function parameters.
---
ChangeLog | 11 +++++++++++
src/roff/troff/input.cpp | 33 +++++++++++++++++++--------------
2 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2e53b2021..f8ebcc66a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-11-30 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp: Trivially refactor. Rename function
+ `read_delimited_number()` to `read_delimited_measurement()` to
+ reinforce the fact that it reads a measurement (which is, in
+ turn, numeric expression potentially including operators).
+ (read_delimited_number): Rename (overloaded) declarations and
+ definitions from these...
+ (read_delimited_measurement): ...to these.
+ (token::next): Update call sites.
+
2025-11-30 G. Branden Robinson <[email protected]>
* src/roff/troff/number.cpp (is_valid_expression)
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 7c8347e3e..ee070db48 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -173,8 +173,10 @@ static void interpolate_environment_variable(symbol);
static symbol composite_glyph_name(symbol);
static void interpolate_arg(symbol);
static request_or_macro *lookup_request(symbol);
-static bool read_delimited_number(units *, unsigned char);
-static bool read_delimited_number(units *, unsigned char, units);
+static bool read_delimited_measurement(units *,
+ unsigned char /* scaling unit */);
+static bool read_delimited_measurement(units *,
+ unsigned char /* scaling unit */, units /* previous value */);
static symbol do_get_long_name(bool, char);
static bool get_line_arg(units *res, unsigned char si, charinfo **cp);
static bool read_size(int *);
@@ -2474,7 +2476,7 @@ void token::next()
break;
}
case 'h':
- if (!read_delimited_number(&x, 'm'))
+ if (!read_delimited_measurement(&x, 'm'))
break;
type = TOKEN_HORIZONTAL_SPACE;
nd = new hmotion_node(x, curenv->get_fill_color());
@@ -2483,12 +2485,13 @@ void token::next()
// don't take height increments relative to previous height if
// in compatibility mode
if (!want_att_compat && curenv->get_char_height()) {
- if (read_delimited_number(&x, 'z', curenv->get_char_height()))
+ if (read_delimited_measurement(&x, 'z',
+ curenv->get_char_height()))
curenv->set_char_height(x);
}
else {
- if (read_delimited_number(&x, 'z',
- curenv->get_requested_point_size()))
+ if (read_delimited_measurement(&x, 'z',
+ curenv->get_requested_point_size()))
curenv->set_char_height(x);
}
if (!want_att_compat)
@@ -2541,7 +2544,8 @@ void token::next()
break;
}
case 'N':
- if (!read_delimited_number(&val, 0))
+ // The argument is a glyph index, which is dimensionless.
+ if (!read_delimited_measurement(&val, 0 /* dimensionless */))
break;
type = TOKEN_INDEXED_CHAR;
return;
@@ -2582,7 +2586,8 @@ void token::next()
have_formattable_input = true;
break;
case 'S':
- if (read_delimited_number(&x, 0))
+ // The argument is in degrees, which are dimensionless.
+ if (read_delimited_measurement(&x, 0 /* dimensionless */))
curenv->set_char_slant(x);
if (!want_att_compat)
have_formattable_input = true;
@@ -2597,7 +2602,7 @@ void token::next()
curenv->get_fill_color());
return;
case 'v':
- if (!read_delimited_number(&x, 'v'))
+ if (!read_delimited_measurement(&x, 'v'))
break;
type = TOKEN_NODE;
nd = new vmotion_node(x, curenv->get_fill_color());
@@ -2616,7 +2621,7 @@ void token::next()
do_width();
break;
case 'x':
- if (!read_delimited_number(&x, 'v'))
+ if (!read_delimited_measurement(&x, 'v'))
break;
type = TOKEN_NODE;
nd = new extra_size_node(x);
@@ -5898,9 +5903,9 @@ static void interpolate_number_format(symbol nm)
input_stack::push(make_temp_iterator(r->get_format()));
}
-static bool read_delimited_number(units *n,
- unsigned char si,
- int prev_value)
+static bool read_delimited_measurement(units *n,
+ unsigned char si,
+ int prev_value)
{
token start_token;
start_token.next();
@@ -5936,7 +5941,7 @@ static bool read_delimited_number(units *n,
return false;
}
-static bool read_delimited_number(units *n, unsigned char si)
+static bool read_delimited_measurement(units *n, unsigned char si)
{
token start_token;
start_token.next();
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit