gbranden pushed a commit to branch master
in repository groff.
commit b8a3ac16176d9e0047eed051f9c7c50d7b793c35
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Apr 27 17:50:26 2026 -0500
src/roff/troff/number.cpp: Slightly refactor.
* src/roff/troff/number.cpp: Convince any compiler that we're not
falling off the end of functions returning `bool` (or
`incr_number_result`). End function bodies with an unconditional
`return`.
(read_vunits, read_hunits, read_measurement, read_integer)
(get_incr_number): Do it.
---
ChangeLog | 9 +++++++++
src/roff/troff/number.cpp | 19 +++++++++----------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ff24d3eba..a7926a056 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-04-27 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/number.cpp: Slightly refactor. Convince any
+ compiler that we're not falling off the end of functions
+ returning `bool` (or `incr_number_result`). End function bodies
+ with an unconditional `return`.
+ (read_vunits, read_hunits, read_measurement, read_integer)
+ (get_incr_number): Do it.
+
2026-04-27 G. Branden Robinson <[email protected]>
[troff]: Stop reporting number format for read-only registers.
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index fda90f4de..f2811d96a 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -70,8 +70,7 @@ bool read_vunits(vunits *res, unsigned char si) // TODO:
grochar
*res = vunits(x);
return true;
}
- else
- return false;
+ return false;
}
bool read_hunits(hunits *res, unsigned char si) // TODO: grochar
@@ -83,8 +82,7 @@ bool read_hunits(hunits *res, unsigned char si) // TODO:
grochar
*res = hunits(x);
return true;
}
- else
- return false;
+ return false;
}
bool read_measurement(units *res,
@@ -99,8 +97,7 @@ bool read_measurement(units *res,
*res = x;
return true;
}
- else
- return false;
+ return false;
}
bool read_integer(int *res)
@@ -113,8 +110,7 @@ bool read_integer(int *res)
*res = x;
return true;
}
- else
- return false;
+ return false;
}
enum incr_number_result { INVALID, ASSIGN, INCREMENT, DECREMENT };
@@ -246,10 +242,13 @@ static incr_number_result get_incr_number(units *res,
}
if (is_valid_expression(res, si, false /* is_parenthesized */))
return result;
- else
- return INVALID;
+ return INVALID;
}
+// TODO: This is a pretty crude test: it doesn't check the first
+// character of a putative numeric expression to see if it makes any
+// sense. Can we be more scrupulous at our call sites and turn this
+// into a simple `inline` assert(3)ion?
static bool is_valid_expression_start()
{
tok.skip_spaces();
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit