gbranden pushed a commit to branch master
in repository groff.
commit 95bf24d299338f92cd00538f8a34c6a5c004b256
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Apr 27 17:55:52 2026 -0500
src/roff/troff/number.cpp: Trivially refactor.
* src/roff/troff/number.cpp: Rename `incr_number_result` enumeration
type to `crement`. Annotate it. Rename `get_incr_number()` to
`read_crement()`. We're pretty close to exclusive use of function
names starting with "read_" for input stream reading operations; that
is, interpretation of *roff language. This change moves us closer to
that goal.
(get_incr_number): Rename this...
(read_crement): ...to this. Update its return type.
(read_vunits, read_hunits, read_measurement_crement)
(read_integer_crement): Update call sites.
---
ChangeLog | 14 ++++++++++++++
src/roff/troff/number.cpp | 22 ++++++++++++----------
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a7926a056..ed81a1f0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2026-04-27 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/number.cpp: Trivially refactor. Rename
+ `incr_number_result` enumeration type to `crement`. Annotate
+ it. Rename `get_incr_number()` to `read_crement()`. We're
+ pretty close to exclusive use of function names starting with
+ "read_" for input stream reading operations; that is,
+ interpretation of *roff language. This change moves us closer
+ to that goal.
+ (get_incr_number): Rename this...
+ (read_crement): ...to this. Update its return type.
+ (read_vunits, read_hunits, read_measurement_crement)
+ (read_integer_crement): Update call sites.
+
2026-04-27 G. Branden Robinson <[email protected]>
* src/roff/troff/number.cpp: Slightly refactor. Convince any
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index f2811d96a..a48638b8f 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -113,10 +113,13 @@ bool read_integer(int *res)
return false;
}
-enum incr_number_result { INVALID, ASSIGN, INCREMENT, DECREMENT };
+// A "crement" is a *roff numeric expression that accepts an optional
+// leading sign (plus or minus) to alter a value relative to its
+// existing magnitude.
+enum crement { INVALID, ASSIGN, INCREMENT, DECREMENT };
-static incr_number_result get_incr_number(units * /* res */,
- unsigned char /* si */); // TODO:
grochar
+static crement read_crement(units * /* res */,
+ unsigned char /* si */); // TODO: grochar
bool read_vunits(vunits *res,
unsigned char si, // TODO: grochar
@@ -126,7 +129,7 @@ bool read_vunits(vunits *res,
// Use a primitive temporary because having the ckd macros store to
// &(res->n) requires `friend` access and produces wrong results.
int i;
- switch (get_incr_number(&v, si)) {
+ switch (read_crement(&v, si)) {
case INVALID:
return false;
case ASSIGN:
@@ -156,7 +159,7 @@ bool read_hunits(hunits *res,
// Use a primitive temporary because having the ckd macros store to
// &(res->n) requires `friend` access and produces wrong results.
int i;
- switch (get_incr_number(&h, si)) {
+ switch (read_crement(&h, si)) {
case INVALID:
return false;
case ASSIGN:
@@ -183,7 +186,7 @@ bool read_measurement_crement(units *res,
units operand)
{
units u;
- switch (get_incr_number(&u, si)) {
+ switch (read_crement(&u, si)) {
case INVALID:
return false;
case ASSIGN:
@@ -206,7 +209,7 @@ bool read_measurement_crement(units *res,
bool read_integer_crement(int *res, int operand)
{
units i;
- switch (get_incr_number(&i, 0)) {
+ switch (read_crement(&i, 0)) {
case INVALID:
return false;
case ASSIGN:
@@ -226,12 +229,11 @@ bool read_integer_crement(int *res, int operand)
return true;
}
-static incr_number_result get_incr_number(units *res,
- unsigned char si) // TODO: grochar
+static crement read_crement(units *res, unsigned char si) // TODO: grochar
{
if (!is_valid_expression_start())
return INVALID;
- incr_number_result result = ASSIGN;
+ crement result = ASSIGN;
if (tok.ch() == int('+')) { // TODO: grochar
tok.next();
result = INCREMENT;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit