gbranden pushed a commit to branch master
in repository groff.

commit 45370e6502ed35e28fd75be0a0d0db41b82ddaf1
Author: Alejandro Colomar <[email protected]>
AuthorDate: Sun Dec 7 16:56:16 2025 +0100

    [hpftodit]: Use countof() instead of SIZEOF().
    
    * src/utils/hpftodit/hpftodit.cpp: Include "stdcountof.h" header file.
      Drop `SIZEOF()` function-like preprocessor macro.
    
      (output_ligatures): Use `countof()` instead of `SIZEOF()`.
    
    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                       | 10 ++++++++++
 src/utils/hpftodit/hpftodit.cpp |  6 +++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 35e2b3725..8f295669c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-12-07  Alejandro Colomar <[email protected]>
+
+       * src/utils/hpftodit/hpftodit.cpp: Include "stdcountof.h" header
+       file.  Drop `SIZEOF()` function-like preprocessor macro.
+       (output_ligatures): Use `countof()` instead of `SIZEOF()`.
+
+       countof() is [expected to be --GBR] standard (ISO C2y).
+
+       Continues the long process of fixing Savannah #66518.
+
 2025-12-07  Alejandro Colomar <[email protected]>
 
        * src/devices/grolbp/lbp.cpp:
diff --git a/src/utils/hpftodit/hpftodit.cpp b/src/utils/hpftodit/hpftodit.cpp
index 62d0c9667..ba6556ee0 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, '_')
@@ -829,7 +829,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;
@@ -838,7 +838,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");

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to