gbranden pushed a commit to branch master
in repository groff.
commit 866449e92198a5d7aa664c24e6e8e772fe5e92e7
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri May 16 06:14:01 2025 -0500
src/roff/troff/input.cpp: Trivially refactor.
* src/roff/troff/input.cpp: Trivially refactor. Give the anonymous
`struct` type used for `warning_table` a name, so that it can be
passed to a template function in C++98-conformantly.
Preprocessor-include "lib.h" so we can use `array_length()`.
(lookup_warning): Use `array_length()` to compute size of
`warning_table` object.
---
ChangeLog | 9 +++++++++
src/roff/troff/input.cpp | 7 +++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index de9fa0829..dbf5a50c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-05-16 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp: Trivially refactor. Give the
+ anonymous `struct` type used for `warning_table` a name, so that
+ it can be passed to a template function in C++98-conformantly.
+ Preprocessor-include "lib.h" so we can use `array_length()`.
+ (lookup_warning): Use `array_length()` to compute size of
+ `warning_table` object.
+
2025-05-16 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp: Use an _unsigned_ `int` to handle
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 247dddaf8..969396636 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -37,6 +37,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <stack>
#include "json-encode.h" // json_encode_char()
+#include "lib.h" // array_length()
#include "troff.h"
#include "dictionary.h"
@@ -9898,7 +9899,7 @@ static void read_drawing_command_color_arguments(token
&start)
have_formattable_input = true;
}
-static struct {
+static struct warning_category {
const char *name;
unsigned int mask;
} warning_table[] = {
@@ -9929,9 +9930,7 @@ static struct {
static unsigned int lookup_warning(const char *name)
{
- for (unsigned int i = 0U;
- i < sizeof(warning_table)/sizeof(warning_table[0]);
- i++)
+ for (unsigned int i = 0U; i < array_length(warning_table); i++)
if (strcmp(name, warning_table[i].name) == 0)
return warning_table[i].mask;
return 0U;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit