gbranden pushed a commit to branch master in repository groff. commit 55739bcce7ea8378e90f724d3561ea2ed3d50d40 Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Fri Jul 11 06:57:26 2025 -0500
[addftinfo]: Fix code style nits. * src/utils/addftinfo/addftinfo.cpp: Give the anonymous `struct` type used for `param_table` a name, `parameter`, so it can be passed to a template function C++98-conformantly. (main): Use `array_length()` on `param_table` instead of `sizeof` and division. --- ChangeLog | 9 +++++++++ src/utils/addftinfo/addftinfo.cpp | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bad7f1967..01b8d7487 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2025-07-11 G. Branden Robinson <g.branden.robin...@gmail.com> + + * src/utils/addftinfo/addftinfo.cpp: Fix code style nits. Give + the anonymous `struct` type used for `param_table` a name, + `parameter`, so it can be passed to a template function + C++98-conformantly. + (main): Use `array_length()` on `param_table` instead of + `sizeof` and division. + 2025-07-11 G. Branden Robinson <g.branden.robin...@gmail.com> * src/preproc/refer/label.ypp: Give the anonymous `struct` types diff --git a/src/utils/addftinfo/addftinfo.cpp b/src/utils/addftinfo/addftinfo.cpp index 919b85c66..1ba334b36 100644 --- a/src/utils/addftinfo/addftinfo.cpp +++ b/src/utils/addftinfo/addftinfo.cpp @@ -41,7 +41,7 @@ static void convert_font(const font_params &, FILE *, FILE *); typedef int font_params::*param_t; -static struct { +static struct parameter { const char *name; param_t par; } param_table[] = { @@ -115,7 +115,7 @@ int main(int argc, char **argv) usage("option requires argument"); size_t j; for (j = 0;; j++) { - if (j >= sizeof(param_table)/sizeof(param_table[0])) + if (j >= array_length(param_table)) fatal("parameter '%1' not recognized", argv[i] + 1); if (strcmp(param_table[j].name, argv[i] + 1) == 0) break; @@ -137,7 +137,7 @@ int main(int argc, char **argv) static void usage(FILE *stream) { fprintf(stream, "usage: %s", program_name); - size_t len = sizeof(param_table)/sizeof(param_table[0]); + size_t len = array_length(param_table); for (size_t i = 0; i < len; i++) fprintf(stream, " [-%s n]", param_table[i].name); fputs(" resolution unit-width font\n", stream); _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit