gbranden pushed a commit to branch master
in repository groff.

commit 151cfb54b6a0d5bd5d843cfac0ee2bd889f7f8fd
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Fri Jun 6 14:10:49 2025 -0500

    [grolj4]: Trivially refactor.
    
    * src/devices/grolj4/lj4.cpp
      (class lj4_font): Comment member function formal argument names as a
      compromise with the Stroustrup-style C++ used in most of groff.
    
      (struct option)
      (main): Spell null pointer constant the idiomatic C++98 way (`0`)
      instead of as `NULL`.
    
      (lj4_font::handle_unknown_font_command): Rename argument from
      `filename` to `fn` to preëmpt `-Wshadow` compiler warning with planned
      refactoring of `class font`.
    
    Also annotate null pointers with `nullptr` comment to ease any future
    transition to C++11, which defines it as a keyword.
---
 ChangeLog                  | 13 +++++++++++
 src/devices/grolj4/lj4.cpp | 55 ++++++++++++++++++++++++++--------------------
 2 files changed, 44 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a5a033099..96a527856 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2025-06-06  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       * src/devices/grolj4/lj4.cpp
+       (class lj4_font): Comment member function formal argument names
+       as a compromise with the Stroustrup-style C++ used in most of
+       groff.
+       (struct option)
+       (main): Spell null pointer constant the idiomatic C++98 way
+       {`0`} instead of as `NULL`.
+       (lj4_font::handle_unknown_font_command): Rename argument from
+       `filename` to `fn` to preëmpt `-Wshadow` compiler warning with
+       planned refactoring of `class font`.
+
 2025-06-06  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        * src/devices/grolbp/lbp.cpp
diff --git a/src/devices/grolj4/lj4.cpp b/src/devices/grolj4/lj4.cpp
index 70b178379..bc61ff15e 100644
--- a/src/devices/grolj4/lj4.cpp
+++ b/src/devices/grolj4/lj4.cpp
@@ -97,15 +97,17 @@ static int lookup_paper_size(const char *);
 class lj4_font : public font {
 public:
   ~lj4_font();
-  void handle_unknown_font_command(const char *command, const char *arg,
-                                  const char *filename, int lineno);
-  static lj4_font *load_lj4_font(const char *);
+  void handle_unknown_font_command(const char * /* command */,
+                                  const char * /* arg */,
+                                  const char * /* fn */,
+                                  int lineno);
+  static lj4_font *load_lj4_font(const char * /* s */);
   int weight;
   int style;
   int proportional;
   int typeface;
 private:
-  lj4_font(const char *);
+  lj4_font(const char * /* nm */);
 };
 
 lj4_font::lj4_font(const char *nm)
@@ -122,7 +124,7 @@ lj4_font *lj4_font::load_lj4_font(const char *s)
   lj4_font *f = new lj4_font(s);
   if (!f->load()) {
     delete f;
-    return 0;
+    return 0 /* nullptr */;
   }
   return f;
 }
@@ -141,30 +143,30 @@ static struct lj4_command_table {
 
 void lj4_font::handle_unknown_font_command(const char *command,
                                           const char *arg,
-                                          const char *filename,
+                                          const char *fn,
                                           int lineno)
 {
   for (size_t i = 0; i < array_length(command_table); i++) {
     if (strcmp(command, command_table[i].s) == 0) {
-      if (arg == 0)
-       fatal_with_file_and_line(filename, lineno,
+      if (arg == 0 /* nullptr */)
+       fatal_with_file_and_line(fn, lineno,
                                 "'%1' command requires an argument",
                                 command);
       char *ptr;
       long n = strtol(arg, &ptr, 10);
       if (ptr == arg)
-       fatal_with_file_and_line(filename, lineno,
+       fatal_with_file_and_line(fn, lineno,
                                 "'%1' command requires numeric"
                                 " argument", command);
       if (n < command_table[i].min) {
-       error_with_file_and_line(filename, lineno,
+       error_with_file_and_line(fn, lineno,
                                 "'%1' command argument must not be"
                                 " less than %2", command,
                                 command_table[i].min);
        n = command_table[i].min;
       }
       else if (n > command_table[i].max) {
-       error_with_file_and_line(filename, lineno,
+       error_with_file_and_line(fn, lineno,
                                 "'%1' command argument must not be"
                                 " greater than %2", command,
                                 command_table[i].max);
@@ -180,19 +182,24 @@ class lj4_printer : public printer {
 public:
   lj4_printer(int);
   ~lj4_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, int dot = 0);
+  void set_line_thickness(int /* size */, int /* dot */ = 0);
   void hpgl_init();
   void hpgl_start();
   void hpgl_end();
-  int moveto(int hpos, int vpos);
-  int moveto1(int hpos, int vpos);
+  int moveto(int /* hpos */, int /* vpos */);
+  int moveto1(int /* hpos */, int /* vpos */);
 
   int cur_hpos;
   int cur_vpos;
@@ -230,7 +237,7 @@ void lj4_printer::hpgl_end()
 
 lj4_printer::lj4_printer(int ps)
 : cur_hpos(-1),
-  cur_font(0),
+  cur_font(0 /* nullptr */),
   cur_size(0),
   cur_symbol_set(0),
   line_thickness(-1),
@@ -626,12 +633,12 @@ int main(int argc, char **argv)
   setbuf(stderr, stderr_buf);
   int c;
   static const struct option long_options[] = {
-    { "help", no_argument, 0, CHAR_MAX + 1 },
-    { "version", no_argument, 0, 'v' },
-    { NULL, 0, 0, 0 }
+    { "help", no_argument, 0 /* nullptr */, CHAR_MAX + 1 },
+    { "version", no_argument, 0 /* nullptr */, 'v' },
+    { 0 /* nullptr */, 0, 0 /* nullptr */, 0 }
   };
   while ((c = getopt_long(argc, argv, ":c:d:F:I:lp:vw:", long_options,
-         NULL)) != EOF)
+         0 /* nullptr */)) != EOF)
     switch(c) {
     case 'l':
       landscape_flag = 1;

_______________________________________________
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to