gbranden pushed a commit to branch master
in repository groff.

commit 8c1368e06cc52a7828abb6c695538be43160763f
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Jun 6 13:39:17 2025 -0500

    [grolbp]: Trivially refactor.
    
    * src/devices/grolbp/lbp.cpp
      (class lbp_font): Comment member function formal argument names as a
      compromise with the Stroustrup-style C++ used in most of groff.
    
      (lbp_font::~lbp_font)
      (lbp_printer::set_line_thickness)
      (struct option)
      (main): Spell null pointer constant the idiomatic C++98 way (`0`)
      instead of as `NULL`.
    
      (lbp_font::handle_unknown_font_command)
      (handle_unknown_desc_command): Rename argument from `filename` to `fn`
      to preëmpt `-Wshadow` compiler warning with planned refactoring of
      `class font`.
---
 ChangeLog                  | 16 +++++++++++
 src/devices/grolbp/lbp.cpp | 72 +++++++++++++++++++++++++---------------------
 2 files changed, 56 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index caad58590..a5a033099 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2025-06-06  G. Branden Robinson <[email protected]>
+
+       * src/devices/grolbp/lbp.cpp
+       (class lbp_font): Comment member function formal argument names
+       as a compromise with the Stroustrup-style C++ used in most of
+       groff.
+       (lbp_font::~lbp_font)
+       (lbp_printer::set_line_thickness)
+       (struct option)
+       (main): Spell null pointer constant the idiomatic C++98 way
+       {`0`} instead of as `NULL`.
+       (lbp_font::handle_unknown_font_command)
+       (handle_unknown_desc_command): Rename argument from `filename`
+       to `fn` to preëmpt `-Wshadow` compiler warning with planned
+       refactoring of `class font`.
+
 2025-06-04  G. Branden Robinson <[email protected]>
 
        * src/devices/grodvi/dvi.cpp
diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
index 53c703ab4..64d60f2cd 100644
--- a/src/devices/grolbp/lbp.cpp
+++ b/src/devices/grolbp/lbp.cpp
@@ -64,9 +64,11 @@ static int set_papersize(const char *paperformat);
 class lbp_font : public font {
 public:
   ~lbp_font();
-  void handle_unknown_font_command(const char *command, const char *arg,
-                                  const char *filename, int lineno);
-  static lbp_font *load_lbp_font(const char *);
+  void handle_unknown_font_command(const char * /* command */,
+                                  const char * /* arg */,
+                                  const char * /* fn */,
+                                  int /* lineno */);
+  static lbp_font *load_lbp_font(const char * /* s */);
   char *lbpname;
   char is_scalable;
 private:
@@ -77,19 +79,24 @@ class lbp_printer : public printer {
 public:
   lbp_printer(int, double, double);
   ~lbp_printer();
-  void set_char(glyph *, font *, const environment *, int, const char *name);
-  void draw(int code, int *p, int np, const environment *env);
-  void begin_page(int);
-  void end_page(int page_length);
-  font *make_font(const char *);
+  void set_char(glyph * /* g */, font * /* f */,
+               const environment * /* env */, int /* w */,
+               const char * /* UNUSED */);
+  void draw(int /* code */, int * /* p */, int /* np */,
+           const environment * /* env */);
+  void begin_page(int /* UNUSED */);
+  void end_page(int /* page_length */);
+  font *make_font(const char * /* nm */);
   void end_of_line();
 private:
-  void set_line_thickness(int size,const environment *env);
+  void set_line_thickness(int /* size */,
+                         const environment * /* env */);
   void vdmstart();
   void vdmflush(); // the name vdmend was already used in lbp.h
-  void setfillmode(int mode);
-  void polygon( int hpos,int vpos,int np,int *p);
-  char *font_name(const lbp_font *f, const int siz);
+  void setfillmode(int /* mode */);
+  void polygon(int /* hpos */, int /* vpos */, int /* np */,
+              int * /* p */);
+  char *font_name(const lbp_font * /* f */, const int /* siz */);
 
   int fill_pattern;
   int fill_mode;
@@ -118,7 +125,7 @@ lbp_font::~lbp_font()
 lbp_font *lbp_font::load_lbp_font(const char *s)
 {
   lbp_font *f = new lbp_font(s);
-  f->lbpname = NULL;
+  f->lbpname = 0 /* nullptr */;
   f->is_scalable = 1; // Default is that fonts are scalable
   if (!f->load()) {
     delete f;
@@ -130,11 +137,11 @@ lbp_font *lbp_font::load_lbp_font(const char *s)
 
 void lbp_font::handle_unknown_font_command(const char *command,
                                           const char *arg,
-                                          const char *filename, int lineno)
+                                          const char *fn, int lineno)
 {
   if (strcmp(command, "lbpname") == 0) {
     if (arg == 0)
-      fatal_with_file_and_line(filename, lineno,
+      fatal_with_file_and_line(fn, lineno,
                               "'%1' command requires an argument",
                               command);
     this->lbpname = new char[strlen(arg) + 1];
@@ -145,7 +152,7 @@ void lbp_font::handle_unknown_font_command(const char 
*command,
     // fprintf(stderr, "Loading font \"%s\" \n", arg);
   }
   // fprintf(stderr, "Loading font  %s \"%s\" in %s at %d\n",
-  //         command, arg, filename, lineno);
+  //         command, arg, fn, lineno);
 }
 
 static void wp54charset()
@@ -208,7 +215,8 @@ lbp_printer::~lbp_printer()
   lbpputs("\033c\033<");
 }
 
-inline void lbp_printer::set_line_thickness(int size,const environment *env)
+inline void lbp_printer::set_line_thickness(int size,
+                                           const environment *env)
 {
       if (size == 0)
        line_thickness = 1;
@@ -373,7 +381,7 @@ void lbp_printer::vdmstart()
   errno = 0;
   f = tmpfile();
   // f = fopen("/tmp/gtmp","w+");
-  if (f == NULL)
+  if (0 /* nullptr */ == f)
     perror("Opening temporary file");
   vdminit(f);
   if (!changed_origin) {       // we should change the origin only one time
@@ -398,7 +406,7 @@ lbp_printer::vdmflush()
   } while (bytes_read == sizeof(buffer));
   fclose(vdmoutput);   // This will also delete the file,
                        // since it is created by tmpfile()
-  vdmoutput = NULL;
+  vdmoutput = 0 /* nullptr */;
 }
 
 inline void lbp_printer::setfillmode(int mode)
@@ -601,7 +609,7 @@ static int set_papersize(const char *paperformat)
 }
 
 static void handle_unknown_desc_command(const char *command, const char *arg,
-                                       const char *filename, int lineno)
+                                       const char *fn, int lineno)
 {
   // orientation command
   if (strcasecmp(command, "orientation") == 0) {
@@ -609,7 +617,7 @@ static void handle_unknown_desc_command(const char 
*command, const char *arg,
     if (orientation > 0)
       return;
     if (arg == 0)
-      error_with_file_and_line(filename, lineno,
+      error_with_file_and_line(fn, lineno,
                               "'orientation' command requires an argument");
     else {
       if (strcasecmp(arg, "portrait") == 0)
@@ -618,7 +626,7 @@ static void handle_unknown_desc_command(const char 
*command, const char *arg,
        if (strcasecmp(arg, "landscape") == 0)
          orientation = 1;
        else
-         error_with_file_and_line(filename, lineno,
+         error_with_file_and_line(fn, lineno,
                                   "invalid argument to 'orientation' command");
       }
     }
@@ -626,15 +634,15 @@ static void handle_unknown_desc_command(const char 
*command, const char *arg,
 }
 
 static struct option long_options[] = {
-  { "orientation", required_argument, NULL, 'o' },
-  { "version", no_argument, NULL, 'v' },
-  { "copies", required_argument, NULL, 'c' },
-  { "landscape", no_argument, NULL, 'l' },
-  { "papersize", required_argument, NULL, 'p' },
-  { "linewidth", required_argument, NULL, 'w' },
-  { "fontdir", required_argument, NULL, 'F' },
-  { "help", no_argument, NULL, 'h' },
-  { NULL, 0, 0, 0 }
+  { "orientation", required_argument, 0 /* nullptr */, 'o' },
+  { "version", no_argument, 0 /* nullptr */, 'v' },
+  { "copies", required_argument, 0 /* nullptr */, 'c' },
+  { "landscape", no_argument, 0 /* nullptr */, 'l' },
+  { "papersize", required_argument, 0 /* nullptr */, 'p' },
+  { "linewidth", required_argument, 0 /* nullptr */, 'w' },
+  { "fontdir", required_argument, 0 /* nullptr */, 'F' },
+  { "help", no_argument, 0 /* nullptr */, 'h' },
+  { 0 /* nullptr */, 0, 0, 0 }
 };
 
 static void usage(FILE *stream)
@@ -658,7 +666,7 @@ static void usage(FILE *stream)
 
 int main(int argc, char **argv)
 {
-  if (program_name == NULL)
+  if (0 /* nullptr */ == program_name)
     program_name = strsave(argv[0]);
   font::set_unknown_desc_command_handler(handle_unknown_desc_command);
   // command line parsing

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

Reply via email to