gbranden pushed a commit to branch master
in repository groff.
commit 81bf236e4a0067df448515498c2ef83e75e123ff
Author: Alejandro Colomar <[email protected]>
AuthorDate: Sun Dec 7 16:56:13 2025 +0100
Use countof() instead of array_length().
* src/devices/grolbp/lbp.cpp:
* src/devices/grolj4/lj4.cpp:
* src/devices/grops/ps.cpp:
* src/devices/grops/psrm.cpp:
* src/libs/libgroff/font.cpp:
* src/libs/libgroff/glyphuni.cpp:
* src/libs/libgroff/make-uniuni:
* src/libs/libgroff/uniuni.cpp:
* src/preproc/eqn/box.cpp:
* src/preproc/eqn/lex.cpp:
* src/preproc/pic/pic.ypp:
* src/preproc/preconv/preconv.cpp:
* src/roff/troff/input.cpp:
* src/utils/addftinfo/addftinfo.cpp: Include "stdcountof.h" header file.
* src/devices/grolbp/lbp.cpp (set_papersize):
* src/devices/grolj4/lj4.cpp
(lj4_font::handle_unknown_font_command, lookup_paper_size):
* src/devices/grops/ps.cpp (ps_printer::special):
* src/devices/grops/psrm.cpp (resource_manager::process_file):
* src/libs/libgroff/font.cpp (font::load_desc):
* src/libs/libgroff/glyphuni.cpp
(glyph_to_unicode_init::glyph_to_unicode_init):
* src/libs/libgroff/make-uniuni
(unicode_decompose_init::unicode_decompose_init):
* src/libs/libgroff/uniuni.cpp
(unicode_decompose_init::unicode_decompose_init):
* src/preproc/eqn/box.cpp (set_param, reset_param, get_param)
(init_param_table, free_param_table):
* src/preproc/eqn/lex.cpp (init_table):
* src/preproc/pic/pic.ypp (define_variable, reset, reset_all):
* src/preproc/preconv/preconv.cpp (get_BOM):
* src/roff/troff/input.cpp (lookup_warning):
* src/utils/addftinfo/addftinfo.cpp (main, usage): Use countof() instead
of [groff's template function --GBR] array_length().
* src/devices/grops/psrm.cpp: Initialize constant globals with
`countof()` instead of `array_length()`.
countof() is [expected to be --GBR] standard (ISO C2y).
Continues the long process of fixing Savannah #66518.
Signed-off-by: Alejandro Colomar <[email protected]>
---
ChangeLog | 46 +++++++++++++++++++++++++++++++++++++++
src/devices/grolbp/lbp.cpp | 5 +++--
src/devices/grolj4/lj4.cpp | 5 +++--
src/devices/grops/ps.cpp | 3 ++-
src/devices/grops/psrm.cpp | 11 +++++-----
src/include/lib.h | 8 -------
src/libs/libgroff/font.cpp | 6 ++---
src/libs/libgroff/glyphuni.cpp | 4 +++-
src/libs/libgroff/make-uniuni | 4 +++-
src/libs/libgroff/uniuni.cpp | 4 +++-
src/preproc/eqn/box.cpp | 14 +++++++-----
src/preproc/eqn/lex.cpp | 11 +++++-----
src/preproc/pic/pic.ypp | 7 +++---
src/preproc/preconv/preconv.cpp | 5 +++--
src/roff/troff/input.cpp | 4 ++--
src/utils/addftinfo/addftinfo.cpp | 5 +++--
16 files changed, 98 insertions(+), 44 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index cf7ddc30c..35e2b3725 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,49 @@
+2025-12-07 Alejandro Colomar <[email protected]>
+
+ * src/devices/grolbp/lbp.cpp:
+ * src/devices/grolj4/lj4.cpp:
+ * src/devices/grops/ps.cpp:
+ * src/devices/grops/psrm.cpp:
+ * src/libs/libgroff/font.cpp:
+ * src/libs/libgroff/glyphuni.cpp:
+ * src/libs/libgroff/make-uniuni:
+ * src/libs/libgroff/uniuni.cpp:
+ * src/preproc/eqn/box.cpp:
+ * src/preproc/eqn/lex.cpp:
+ * src/preproc/pic/pic.ypp:
+ * src/preproc/preconv/preconv.cpp:
+ * src/roff/troff/input.cpp:
+ * src/utils/addftinfo/addftinfo.cpp: Include "stdcountof.h"
+ header file.
+
+ * src/devices/grolbp/lbp.cpp (set_papersize):
+ * src/devices/grolj4/lj4.cpp
+ (lj4_font::handle_unknown_font_command, lookup_paper_size):
+ * src/devices/grops/ps.cpp (ps_printer::special):
+ * src/devices/grops/psrm.cpp (resource_manager::process_file):
+ * src/libs/libgroff/font.cpp (font::load_desc):
+ * src/libs/libgroff/glyphuni.cpp
+ (glyph_to_unicode_init::glyph_to_unicode_init):
+ * src/libs/libgroff/make-uniuni
+ (unicode_decompose_init::unicode_decompose_init):
+ * src/libs/libgroff/uniuni.cpp
+ (unicode_decompose_init::unicode_decompose_init):
+ * src/preproc/eqn/box.cpp (set_param, reset_param, get_param)
+ (init_param_table, free_param_table):
+ * src/preproc/eqn/lex.cpp (init_table):
+ * src/preproc/pic/pic.ypp (define_variable, reset, reset_all):
+ * src/preproc/preconv/preconv.cpp (get_BOM):
+ * src/roff/troff/input.cpp (lookup_warning):
+ * src/utils/addftinfo/addftinfo.cpp (main, usage): Use countof()
+ instead of [groff's template function --GBR] array_length().
+
+ * src/devices/grops/psrm.cpp: Initialize constant globals with
+ `countof()` instead of `array_length()`.
+
+ countof() is [expected to be --GBR] standard (ISO C2y).
+
+ Continues the long process of fixing Savannah #66518.
+
2025-12-07 Alejandro Colomar <[email protected]>
* bootstrap.conf (gnulib_modules): Add stdcountof-h.
diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
index 3b881dc16..7b4d85695 100644
--- a/src/devices/grolbp/lbp.cpp
+++ b/src/devices/grolbp/lbp.cpp
@@ -31,6 +31,7 @@ TODO
#include <errno.h>
#include <limits.h> // INT_MAX
#include <math.h> // fabs(), sqrt()
+#include <stdcountof.h>
#include <stdlib.h> // abs(), EXIT_SUCCESS, exit(), strtol()
#include <string.h> // strcmp(), strcpy(), strlen(), strncpy()
#include <strings.h> // strcasecmp()
@@ -42,7 +43,7 @@ TODO
#include "charset.h"
#include "driver.h"
#include "lbp.h"
-#include "lib.h" // array_length(), strsave()
+#include "lib.h" // strsave()
#include "paper.h"
extern "C" const char *Version_string;
@@ -599,7 +600,7 @@ static int set_papersize(const char *paperformat)
unsigned int i;
// First, test for a standard (i.e. supported directly by the printer)
// paper format.
- for (i = 0 ; i < array_length(lbp_papersizes); i++)
+ for (i = 0 ; i < countof(lbp_papersizes); i++)
{
if (strcasecmp(lbp_papersizes[i].name,paperformat) == 0)
return lbp_papersizes[i].code;
diff --git a/src/devices/grolj4/lj4.cpp b/src/devices/grolj4/lj4.cpp
index d2f7b1d9b..d0b9ef54c 100644
--- a/src/devices/grolj4/lj4.cpp
+++ b/src/devices/grolj4/lj4.cpp
@@ -37,6 +37,7 @@ X command to include bitmap graphics
#include <assert.h>
#include <locale.h> // setlocale()
#include <math.h> // atan2(), floor()
+#include <stdcountof.h>
#include <stdio.h> // EOF, FILE, fflush(), fprintf(), printf(),
// setbuf(), stderr, stdout
#include <stdlib.h> // exit(), EXIT_SUCCESS, strtol()
@@ -144,7 +145,7 @@ void lj4_font::handle_unknown_font_command(const char
*command,
const char *fn,
int lineno)
{
- for (size_t i = 0; i < array_length(command_table); i++) {
+ for (size_t i = 0; i < countof(command_table); i++) {
if (strcmp(command, command_table[i].s) == 0) {
if (0 /* nullptr */ == arg)
fatal_with_file_and_line(fn, lineno,
@@ -179,7 +180,7 @@ void lj4_font::handle_unknown_font_command(const char
*command,
static ssize_t lookup_paper_size(const char *s)
{
// C++11: constexpr
- const size_t paper_table_length = array_length(paper_table);
+ const size_t paper_table_length = countof(paper_table);
// ...and once it's a constexpr, we can do this...
//static_assert(paper_table_length < INT_MAX);
// ...but until then...
diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp
index f92b1cbfb..7f8145902 100644
--- a/src/devices/grops/ps.cpp
+++ b/src/devices/grops/ps.cpp
@@ -30,6 +30,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <locale.h> // setlocale()
#include <math.h> // atan2(), sqrt(), tan()
+#include <stdcountof.h>
#include <stdint.h> // uint16_t
#include <stdio.h> // EOF, FILE, fclose(), fgets(), fileno(), fseek(),
// getc(), SEEK_SET, setbuf(), stderr, stdout
@@ -1633,7 +1634,7 @@ void ps_printer::special(char *arg, const environment
*env, char type)
error("empty X command ignored");
return;
}
- for (size_t i = 0; i < array_length(proc_table); i++)
+ for (size_t i = 0; i < countof(proc_table); i++)
if (strncmp(command, proc_table[i].name, p - command) == 0) {
flush_sbuf();
if (sbuf_color != *env->col)
diff --git a/src/devices/grops/psrm.cpp b/src/devices/grops/psrm.cpp
index cd9e5a990..b6dae99d1 100644
--- a/src/devices/grops/psrm.cpp
+++ b/src/devices/grops/psrm.cpp
@@ -21,13 +21,14 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#endif
#include <errno.h>
+#include <stdcountof.h>
#include <stdio.h> // EOF, FILE, fclose(), fgets(), getc(), ungetc()
#include <stdlib.h> // getenv(), putenv(), strtoul()
#include <string.h> // strerror(), strtok()
#include "cset.h"
#include "driver.h"
-#include "lib.h" // array_length(), strsave()
+#include "lib.h" // strsave()
#include "stringclass.h"
#include "ps.h"
@@ -66,7 +67,7 @@ const char *extension_table[] = {
"FileSystem",
};
-const size_t NEXTENSIONS = array_length(extension_table);
+const size_t NEXTENSIONS = countof(extension_table);
// this must stay in sync with 'resource_type' in 'ps.h'
const char *resource_table[] = {
@@ -79,7 +80,7 @@ const char *resource_table[] = {
"pattern",
};
-const size_t NRESOURCES = array_length(resource_table);
+const size_t NRESOURCES = countof(resource_table);
static bool read_uint_arg(const char **pp, unsigned *res)
{
@@ -946,7 +947,7 @@ void resource_manager::process_file(int rank, FILE *fp,
"DocumentSuppliedFiles:",
};
- const size_t NHEADER_COMMENTS = array_length(header_comment_table);
+ const size_t NHEADER_COMMENTS = countof(header_comment_table);
static const comment_info comment_table[] = {
{ "BeginResource:", &resource_manager::do_begin_resource },
@@ -967,7 +968,7 @@ void resource_manager::process_file(int rank, FILE *fp,
{ "BeginBinary:", &resource_manager::do_begin_binary },
};
- const size_t NCOMMENTS = array_length(comment_table);
+ const size_t NCOMMENTS = countof(comment_table);
string buf;
int saved_lineno = current_lineno;
const char *saved_filename = current_filename;
diff --git a/src/include/lib.h b/src/include/lib.h
index 27ccfdd69..43c576d9e 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -120,14 +120,6 @@ int mksdir(char *tmpl);
static const double PI = 3.14159265358979323846;
-#ifdef __cplusplus
-template <typename T, size_t N>
-// constexpr // C++11
-size_t array_length(T(&)[N]) {
- return N;
-}
-#endif
-
#endif /* GROFF_LIB_H */
// Local Variables:
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp
index 6b7df157b..b3c99dc08 100644
--- a/src/libs/libgroff/font.cpp
+++ b/src/libs/libgroff/font.cpp
@@ -25,11 +25,12 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <limits.h> // INT_MAX, INT_MIN, LONG_MAX
#include <math.h>
+#include <stdcountof.h>
#include <stdlib.h>
#include <string.h> // strerror()
#include <wchar.h>
-#include "lib.h" // array_length()
+#include "lib.h"
#include "errarg.h"
#include "error.h"
@@ -1288,8 +1289,7 @@ const char *font::load_desc()
bool numeric_directive_found = false;
size_t idx;
for (idx = 0;
- (!numeric_directive_found
- && (idx < array_length(numeric_directive_table)));
+ !numeric_directive_found && (idx < countof(numeric_directive_table));
idx++)
if (strcmp(numeric_directive_table[idx].name, p) == 0)
numeric_directive_found = true;
diff --git a/src/libs/libgroff/glyphuni.cpp b/src/libs/libgroff/glyphuni.cpp
index 7294a63aa..396ac6bb6 100644
--- a/src/libs/libgroff/glyphuni.cpp
+++ b/src/libs/libgroff/glyphuni.cpp
@@ -20,6 +20,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
+#include <stdcountof.h>
+
#include "lib.h"
#include "stringclass.h"
@@ -516,7 +518,7 @@ static struct glyph_to_unicode_init {
glyph_to_unicode_init::glyph_to_unicode_init()
{
- for (size_t i = 0; i < array_length(glyph_to_unicode_list); i++) {
+ for (size_t i = 0; i < countof(glyph_to_unicode_list); i++) {
glyph_to_unicode_map *gtu = new glyph_to_unicode_map[1];
gtu->value = (char *)glyph_to_unicode_list[i].value;
glyph_to_unicode_table.define(glyph_to_unicode_list[i].key, gtu);
diff --git a/src/libs/libgroff/make-uniuni b/src/libs/libgroff/make-uniuni
index 1bc1477c2..e0be1d9fa 100755
--- a/src/libs/libgroff/make-uniuni
+++ b/src/libs/libgroff/make-uniuni
@@ -89,6 +89,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
+#include <stdcountof.h>
+
#include "lib.h"
#include "stringclass.h"
@@ -137,7 +139,7 @@ static struct unicode_decompose_init {
unicode_decompose_init::unicode_decompose_init()
{
- for (size_t i = 0; i < array_length(unicode_decompose_list); i++) {
+ for (size_t i = 0; i < countof(unicode_decompose_list); i++) {
unicode_decompose *dec = new unicode_decompose[1];
dec->value = const_cast<char *>(unicode_decompose_list[i].value);
unicode_decompose_table.define(unicode_decompose_list[i].key, dec);
diff --git a/src/libs/libgroff/uniuni.cpp b/src/libs/libgroff/uniuni.cpp
index b3ba3ca47..6d63e73b4 100644
--- a/src/libs/libgroff/uniuni.cpp
+++ b/src/libs/libgroff/uniuni.cpp
@@ -20,6 +20,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
+#include <stdcountof.h>
+
#include "lib.h"
#include "stringclass.h"
@@ -2137,7 +2139,7 @@ static struct unicode_decompose_init {
unicode_decompose_init::unicode_decompose_init()
{
- for (size_t i = 0; i < array_length(unicode_decompose_list); i++) {
+ for (size_t i = 0; i < countof(unicode_decompose_list); i++) {
unicode_decompose *dec = new unicode_decompose[1];
dec->value = const_cast<char *>(unicode_decompose_list[i].value);
unicode_decompose_table.define(unicode_decompose_list[i].key, dec);
diff --git a/src/preproc/eqn/box.cpp b/src/preproc/eqn/box.cpp
index bfc63f23a..a58762d31 100644
--- a/src/preproc/eqn/box.cpp
+++ b/src/preproc/eqn/box.cpp
@@ -20,6 +20,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
+#include <stdcountof.h>
+
#include <assert.h>
#include "eqn.h"
@@ -139,7 +141,7 @@ struct param *param_table = 0 /* nullptr */;
void set_param(const char *name, int value)
{
- for (size_t i = 0; i <= array_length(default_param_table); i++)
+ for (size_t i = 0; i <= countof(default_param_table); i++)
if (strcmp(param_table[i].name, name) == 0) {
*(param_table[i].ptr) = value;
return;
@@ -149,7 +151,7 @@ void set_param(const char *name, int value)
void reset_param(const char *name)
{
- for (size_t i = 0; i < array_length(default_param_table); i++)
+ for (size_t i = 0; i < countof(default_param_table); i++)
if (strcmp(param_table[i].name, name) == 0) {
*param_table[i].ptr = *(default_param_table[i].ptr);
return;
@@ -160,7 +162,7 @@ void reset_param(const char *name)
int get_param(const char *name)
{
- for (size_t i = 0; i < array_length(default_param_table); i++)
+ for (size_t i = 0; i < countof(default_param_table); i++)
if (strcmp(param_table[i].name, name) == 0)
return *(param_table[i].ptr);
assert(0 == "attempted to access parameter not in table");
@@ -169,8 +171,8 @@ int get_param(const char *name)
void init_param_table()
{
- param_table = new param[array_length(default_param_table)];
- for (size_t i = 0; i < array_length(default_param_table); i++) {
+ param_table = new param[countof(default_param_table)];
+ for (size_t i = 0; i < countof(default_param_table); i++) {
param_table[i].name = default_param_table[i].name;
param_table[i].ptr = new int(*(default_param_table[i].ptr));
}
@@ -179,7 +181,7 @@ void init_param_table()
void free_param_table()
{
if (param_table != 0 /* nullptr */) {
- for (size_t i = 0; i < array_length(default_param_table); i++)
+ for (size_t i = 0; i < countof(default_param_table); i++)
delete param_table[i].ptr;
delete[] param_table;
param_table = 0 /* nullptr */;
diff --git a/src/preproc/eqn/lex.cpp b/src/preproc/eqn/lex.cpp
index 8dd35c744..938285ca2 100644
--- a/src/preproc/eqn/lex.cpp
+++ b/src/preproc/eqn/lex.cpp
@@ -20,7 +20,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
-#include "lib.h" // array_length()
+#include <stdcountof.h>
+
#include "ptable.h"
#include "stringclass.h"
@@ -285,13 +286,13 @@ static struct builtin_def mathml_defs[] = {
void init_table(const char *device)
{
unsigned int i;
- for (i = 0; i < array_length(token_table); i++) {
+ for (i = 0; i < countof(token_table); i++) {
definition *def = new definition[1];
def->is_macro = 0;
def->tok = token_table[i].token;
macro_table.define(token_table[i].name, def);
}
- for (i = 0; i < array_length(common_defs); i++) {
+ for (i = 0; i < countof(common_defs); i++) {
definition *def = new definition[1];
def->is_macro = 1;
def->contents = strsave(common_defs[i].def);
@@ -299,7 +300,7 @@ void init_table(const char *device)
macro_table.define(common_defs[i].name, def);
}
if (output_format == troff) {
- for (i = 0; i < array_length(troff_defs); i++) {
+ for (i = 0; i < countof(troff_defs); i++) {
definition *def = new definition[1];
def->is_macro = 1;
def->contents = strsave(troff_defs[i].def);
@@ -308,7 +309,7 @@ void init_table(const char *device)
}
}
else if (output_format == mathml) {
- for (i = 0; i < array_length(mathml_defs); i++) {
+ for (i = 0; i < countof(mathml_defs); i++) {
definition *def = new definition[1];
def->is_macro = 1;
def->contents = strsave(mathml_defs[i].def);
diff --git a/src/preproc/pic/pic.ypp b/src/preproc/pic/pic.ypp
index b79633b68..a97751095 100644
--- a/src/preproc/pic/pic.ypp
+++ b/src/preproc/pic/pic.ypp
@@ -25,6 +25,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h> // EDOM, ERANGE, errno
#include <math.h> // atan2(), cos(), floor(), fmod(), log10(), pow(),
// sin(), sqrt()
+#include <stdcountof.h>
#include <stdio.h> // fflush(), fprintf(), snprintf(), sprintf(), stderr
#include <stdlib.h> // rand(), srand(), system()
#include <string.h> // strcat(), strchr(), strcmp(), strcpy(), strlen()
@@ -1849,7 +1850,7 @@ void define_variable(const char *name, double val)
if (strcmp(name, "scale") == 0) {
// When the scale changes, reset all scaled predefined variables to
// their default values.
- for (size_t i = 0; i < array_length(defaults_table); i++)
+ for (size_t i = 0; i < countof(defaults_table); i++)
if (defaults_table[i].scaled)
define_variable(defaults_table[i].name,
(val * defaults_table[i].val));
@@ -1869,7 +1870,7 @@ void parse_init()
void reset(const char *nm)
{
- for (size_t i = 0; i < array_length(defaults_table); i++)
+ for (size_t i = 0; i < countof(defaults_table); i++)
if (strcmp(nm, defaults_table[i].name) == 0) {
double val = defaults_table[i].val;
if (defaults_table[i].scaled) {
@@ -1889,7 +1890,7 @@ void reset_all()
// aren't scaled because 'scale' is not scaled, and changing the
// value of 'scale' will reset all the predefined variables that
// are scaled.
- for (size_t i = 0; i < array_length(defaults_table); i++)
+ for (size_t i = 0; i < countof(defaults_table); i++)
if (!defaults_table[i].scaled)
define_variable(defaults_table[i].name, defaults_table[i].val);
}
diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp
index 2b8c73bc9..4aa42be2b 100644
--- a/src/preproc/preconv/preconv.cpp
+++ b/src/preproc/preconv/preconv.cpp
@@ -31,6 +31,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
# endif
#endif
#include <locale.h> // setlocale()
+#include <stdcountof.h>
#include <stdio.h> // EOF, FILE, fclose(), ferror(), fflush(), fileno(),
// fopen(), fprintf(), fread(), fseek(), ftell(),
// getc(), printf(), putchar(), rewind(), SEEK_SET,
@@ -44,7 +45,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <getopt.h> // getopt_long()
-#include "lib.h" // array_length()
+#include "lib.h"
#include "errarg.h"
#include "error.h"
@@ -809,7 +810,7 @@ get_BOM(FILE *fp, string &BOM, string &data)
// UTF-8: 0xEFBBBF
// UTF-16: 0xFEFF or 0xFFFE
// UTF-32: 0x0000FEFF or 0xFFFE0000
- const int BOM_table_len = array_length(BOM_table);
+ const int BOM_table_len = countof(BOM_table);
char BOM_string[4];
const char *retval = 0 /* nullptr */;
int len;
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index a48e975e7..59d4b15aa 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -25,6 +25,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <assert.h>
#include <errno.h> // ENOENT, errno
#include <locale.h> // setlocale()
+#include <stdcountof.h>
#include <stdio.h> // EOF, FILE, clearerr(), fclose(), fflush(),
// fileno(), fopen(), fprintf(), fseek(), getc(),
// pclose(), popen(), printf(), SEEK_SET, snprintf(),
@@ -39,7 +40,6 @@ 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"
@@ -10508,7 +10508,7 @@ static struct warning_category {
static unsigned int lookup_warning(const char *name)
{
- for (unsigned int i = 0U; i < array_length(warning_table); i++)
+ for (unsigned int i = 0U; i < countof(warning_table); i++)
if (strcmp(name, warning_table[i].name) == 0)
return warning_table[i].mask;
return 0U;
diff --git a/src/utils/addftinfo/addftinfo.cpp
b/src/utils/addftinfo/addftinfo.cpp
index 7bdf23779..c19d18b07 100644
--- a/src/utils/addftinfo/addftinfo.cpp
+++ b/src/utils/addftinfo/addftinfo.cpp
@@ -21,6 +21,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#endif
#include <errno.h>
+#include <stdcountof.h>
#include <stdlib.h> // exit(), EXIT_SUCCESS, strtol()
#include "lib.h"
@@ -115,7 +116,7 @@ int main(int argc, char **argv)
usage("option requires argument");
size_t j;
for (j = 0;; j++) {
- if (j >= array_length(param_table))
+ if (j >= countof(param_table))
fatal("parameter '%1' not recognized", argv[i] + 1);
if (strcmp(param_table[j].name, argv[i] + 1) == 0)
break;
@@ -137,7 +138,7 @@ int main(int argc, char **argv)
static void usage(FILE *stream)
{
fprintf(stream, "usage: %s", program_name);
- size_t len = array_length(param_table);
+ size_t len = countof(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
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit