[PATCH v5 3/4] [hpftodit]: Use countof() instead of SIZEOF()
Alejandro Colomar <[email protected]>
| Newsgroups | gmane.comp.printing.groff.general |
|---|---|
| Message-ID | <5a1beff06bc5c180cc29cc2d486646e0e4b79898.1765122824.git.alx@kernel.org> |
countof() is standard (ISO C2y). Signed-off-by: Alejandro Colomar <[email protected]> --- src/utils/hpftodit/hpftodit.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/hpftodit/hpftodit.cpp b/src/utils/hpftodit/hpftodit.cpp index 2b52156d8..851fce906 100644 --- a/src/utils/hpftodit/hpftodit.cpp +++ b/src/utils/hpftodit/hpftodit.cpp @@ -30,6 +30,7 @@ put filename in error messages (or fix lib) #include <assert.h> #include <errno.h> #include <math.h> // cos(), sin() +#include <stdcountof.h> #include <stdio.h> // FILE, fclose(), fgets(), fopen(), fprintf(), // freopen(), printf(), sprintf() #include <stdlib.h> // atoi(), exit(), EXIT_FAILURE, EXIT_SUCCESS, @@ -51,7 +52,6 @@ put filename in error messages (or fix lib) extern "C" const char *Version_string; extern const char *hp_msl_to_unicode_code(const char *); -#define SIZEOF(v) (sizeof(v)/sizeof(v[0])) #define equal(a, b) (strcmp(a, b) == 0) // only valid if is_uname(c) has returned true #define is_decomposed(c) strchr(c, '_') @@ -825,7 +825,7 @@ output_ligatures() if (charcode < charcode_name_table_size && char_table[i].symbol_set != NO_SYMBOL_SET) { for (name_list *p = charcode_name_table[charcode]; p; p = p->next) - for (unsigned int j = 0; j < SIZEOF(ligature_chars); j++) + for (unsigned int j = 0; j < countof(ligature_chars); j++) if (strcmp(p->name, ligature_chars[j]) == 0) { ligature_mask |= 1 << j; break; @@ -834,7 +834,7 @@ output_ligatures() } if (ligature_mask) { printf("ligatures"); - for (i = 0; i < SIZEOF(ligature_names); i++) + for (i = 0; i < countof(ligature_names); i++) if (ligature_mask & (1 << i)) printf(" %s", ligature_names[i]); printf(" 0\n"); -- 2.51.0