gbranden pushed a commit to branch master
in repository groff.

commit e1754323e51ea7987d75297958769bc4bb5019f3
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Jul 10 21:43:27 2025 -0500

    [grolbp]: Fix code style nits.
    
    * src/devices/grolbp/lbp.cpp: Give the anonymous `struct` type used for
      `lbp_papersizes` a name, so that it can be passed to a template
      function C++98-conformantly.
    
      (set_papersize): Use `array_length()` on `lbp_papersizes` instead of
      `sizeof` and division.
    
      (wp54charset, lbp_printer::vdmflush): `sizeof` is an operator, not a
      function, so don't parenthesize its operand when it's an lvalue (as
      opposed to a type name).
---
 ChangeLog                  | 11 +++++++++++
 src/devices/grolbp/lbp.cpp | 12 ++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d5beb1727..53840379c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2025-07-10  G. Branden Robinson <[email protected]>
+
+       * src/devices/grolbp/lbp.cpp: Fix code style nits.  Give the
+       anonymous `struct` type used for `lbp_papersizes` a name, so
+       that it can be passed to a template function C++98-conformantly.
+       (set_papersize): Use `array_length()` on `lbp_papersizes`
+       instead of `sizeof` and division.
+       (wp54charset, lbp_printer::vdmflush): `sizeof` is an operator,
+       not a function, so don't parenthesize its operand when it's an
+       lvalue (as opposed to a type name).
+
 2025-07-10  G. Branden Robinson <[email protected]>
 
        [troff]: Catch `std::bad_alloc` exceptions from `new` operator.
diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
index 64d60f2cd..870b9b1f8 100644
--- a/src/devices/grolbp/lbp.cpp
+++ b/src/devices/grolbp/lbp.cpp
@@ -42,7 +42,7 @@ TODO
 #include "charset.h"
 #include "driver.h"
 #include "lbp.h"
-#include "lib.h" // strsave()
+#include "lib.h" // array_length(), strsave()
 #include "paper.h"
 
 extern "C" const char *Version_string;
@@ -159,7 +159,7 @@ static void wp54charset()
 {
   unsigned int i;
   lbpputs("\033[714;100;29;0;32;120.}");
-  for (i = 0; i < sizeof(symset); i++)
+  for (i = 0; i < sizeof symset; i++)
     lbpputc(symset[i]);
   lbpputs("\033[100;0 D");
   return;
@@ -401,9 +401,9 @@ lbp_printer::vdmflush()
   /* let's copy the vdm code to the output */
   rewind(vdmoutput);
   do {
-    bytes_read = fread(buffer, 1, sizeof(buffer), vdmoutput);
+    bytes_read = fread(buffer, 1, sizeof buffer, vdmoutput);
     bytes_read = fwrite(buffer, 1, bytes_read, lbpoutput);
-  } while (bytes_read == sizeof(buffer));
+  } while (bytes_read == sizeof buffer);
   fclose(vdmoutput);   // This will also delete the file,
                        // since it is created by tmpfile()
   vdmoutput = 0 /* nullptr */;
@@ -584,7 +584,7 @@ printer *make_printer()
   return new lbp_printer(user_papersize, user_paperwidth, user_paperlength);
 }
 
-static struct {
+static struct lbp_paper_size {
   const char *name;
   int code;
 } lbp_papersizes[] =
@@ -599,7 +599,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 < sizeof(lbp_papersizes) / sizeof(lbp_papersizes[0]); i++)
+  for (i = 0 ; i < array_length(lbp_papersizes); i++)
   {
     if (strcasecmp(lbp_papersizes[i].name,paperformat) == 0)
       return lbp_papersizes[i].code;

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

Reply via email to