gbranden pushed a commit to branch master
in repository groff.

commit 88870ab4242942a862d18d833b16315f9847f046
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Jul 11 06:10:48 2025 -0500

    [preconv]: Fix code style nits (1/6).
    
    * src/preproc/preconv/preconv.cpp (get_BOM): Give the anonymous `struct`
      type used for `BOM_table` a name, and move it into the global scope
      (it was already `static`), so that it can be passed to a template
      function C++98-conformantly.  Use `array_length()` on `BOM_table`
      instead of `sizeof` and division.
---
 ChangeLog                       |  9 +++++++++
 src/preproc/preconv/preconv.cpp | 27 ++++++++++++++-------------
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0994aa3fe..8c8cd755d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-07-11  G. Branden Robinson <[email protected]>
+
+       * src/preproc/preconv/preconv.cpp: Fix code style nits.
+       (get_BOM): Give the anonymous `struct` type used for `BOM_table`
+       a name, and move it into the global scope (it was already
+       `static`), so that it can be passed to a template function
+       C++98-conformantly.  Use `array_length()` on `BOM_table` instead
+       of `sizeof` and division.
+
 2025-07-11  G. Branden Robinson <[email protected]>
 
        * src/preproc/pic/pic.ypp (object_spec): Revert "workaround for
diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp
index 30531078b..88bad63b4 100644
--- a/src/preproc/preconv/preconv.cpp
+++ b/src/preproc/preconv/preconv.cpp
@@ -44,7 +44,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #include <getopt.h> // getopt_long()
 
-#include "lib.h"
+#include "lib.h" // array_length()
 
 #include "errarg.h"
 #include "error.h"
@@ -769,6 +769,18 @@ conversion_iconv(FILE *fp, const string &data, char *enc)
 }
 #endif /* HAVE_ICONV */
 
+static struct bom_s {
+  int len;
+  const char *str;
+  const char *name;
+} BOM_table[] = {
+  {4, "\x00\x00\xFE\xFF", "UTF-32"},
+  {4, "\xFF\xFE\x00\x00", "UTF-32"},
+  {3, "\xEF\xBB\xBF", "UTF-8"},
+  {2, "\xFE\xFF", "UTF-16"},
+  {2, "\xFF\xFE", "UTF-16"},
+};
+
 // ---------------------------------------------------------
 // Handle Byte Order Mark.
 //
@@ -793,18 +805,7 @@ get_BOM(FILE *fp, string &BOM, string &data)
   //   UTF-8: 0xEFBBBF
   //   UTF-16: 0xFEFF or 0xFFFE
   //   UTF-32: 0x0000FEFF or 0xFFFE0000
-  static struct {
-    int len;
-    const char *str;
-    const char *name;
-  } BOM_table[] = {
-    {4, "\x00\x00\xFE\xFF", "UTF-32"},
-    {4, "\xFF\xFE\x00\x00", "UTF-32"},
-    {3, "\xEF\xBB\xBF", "UTF-8"},
-    {2, "\xFE\xFF", "UTF-16"},
-    {2, "\xFF\xFE", "UTF-16"},
-  };
-  const int BOM_table_len = sizeof (BOM_table) / sizeof (BOM_table[0]);
+  const int BOM_table_len = array_length(BOM_table);
   char BOM_string[4];
   const char *retval = NULL;
   int len;

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

Reply via email to