gbranden pushed a commit to branch master
in repository groff.
commit a9fc753fbb2cb10ed46aced690514e95dbdc3886
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Dec 8 04:46:02 2025 -0600
src/roff/troff/input.cpp: Trivially refactor.
* src/roff/troff/input.cpp: Rename `do_get_long_name()` to
`read_input_until_terminator()` because {A} that's more descriptive of
its function, and {B} it's used for more than just reading "long
names" (GNU troff-style identifiers); in fact 4 out of its 5 call
sites read things that aren't identifiers.
(do_get_long_name): Rename declaration and definition from this...
(read_input_until_terminator): ...to this.
(read_rgb, read_cmy, read_cmyk, read_gray, do_get_long_name): Update
call sites.
---
ChangeLog | 14 ++++++++++++++
src/roff/troff/input.cpp | 21 +++++++++++++--------
2 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b368178a0..7080f3850 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2025-12-08 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp: Trivially refactor. Rename
+ `do_get_long_name()` to `read_input_until_terminator()` because
+ {A} that's more descriptive of its function, and {B} it's used
+ for more than just reading "long names" (GNU troff-style
+ identifiers); in fact 4 out of its 5 call sites read things that
+ aren't identifiers.
+ (do_get_long_name): Rename declaration and definition from
+ this...
+ (read_input_until_terminator): ...to this.
+ (read_rgb, read_cmy, read_cmyk, read_gray, do_get_long_name):
+ Update call sites.
+
2025-12-08 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp: Migrate more input character reading
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 447db1788..659850bfa 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -177,8 +177,8 @@ 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 /* required */,
- unsigned char /* end char */);
+static symbol read_input_until_terminator(bool /* required */,
+ unsigned char /* end char */);
static bool get_line_arg(units *res, unsigned char si, charinfo **cp);
static bool read_size(int *);
static symbol read_delimited_identifier();
@@ -1419,7 +1419,8 @@ static unsigned int get_color_element(const char *scheme,
const char *col)
static color *read_rgb(unsigned char end = 0U)
{
- symbol component = do_get_long_name(false /* required */, end);
+ symbol component = read_input_until_terminator(false /* required */,
+ end);
if (component.is_null()) {
warning(WARN_COLOR, "missing rgb color values");
return 0 /* nullptr */;
@@ -1449,7 +1450,8 @@ static color *read_rgb(unsigned char end = 0U)
static color *read_cmy(unsigned char end = 0U)
{
- symbol component = do_get_long_name(false /* required */, end);
+ symbol component = read_input_until_terminator(false /* required */,
+ end);
if (component.is_null()) {
warning(WARN_COLOR, "missing cmy color values");
return 0 /* nullptr */;
@@ -1479,7 +1481,8 @@ static color *read_cmy(unsigned char end = 0U)
static color *read_cmyk(unsigned char end = 0U)
{
- symbol component = do_get_long_name(false /* required */, end);
+ symbol component = read_input_until_terminator(false /* required */,
+ end);
if (component.is_null()) {
warning(WARN_COLOR, "missing cmyk color values");
return 0 /* nullptr */;
@@ -1510,7 +1513,8 @@ static color *read_cmyk(unsigned char end = 0U)
static color *read_gray(unsigned char end = 0U)
{
- symbol component = do_get_long_name(false /* required */, end);
+ symbol component = read_input_until_terminator(false /* required */,
+ end);
if (component.is_null()) {
warning(WARN_COLOR, "missing gray value");
return 0 /* nullptr */;
@@ -3133,12 +3137,13 @@ symbol read_identifier(bool required)
symbol get_long_name(bool required)
{
- return do_get_long_name(required, 0U);
+ return read_input_until_terminator(required, 0U);
}
// Read bytes from input until reaching a null byte or the specified
// `end_char`; construct and return a `symbol` object therefrom.
-static symbol do_get_long_name(bool required, unsigned char end_char)
+static symbol read_input_until_terminator(bool required,
+ unsigned char end_char)
{
tok.skip_spaces();
int buf_size = default_buffer_size;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit