gbranden pushed a commit to branch master
in repository groff.

commit 8b413cdb04252978da04f1c10b260e8bbcc429a6
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sat Jul 13 12:06:52 2024 -0500

    [libgroff,eqn,pre-grohtml,troff]: Anno nullptrs.
    
    * src/libs/libgroff/font.cpp (struct font_kern_list)
      (struct font_widths_cache, struct text_file, text_file::~text_file)
      (text_file::next_line, text_file::fatal, glyph_to_unicode)
      (font::font, font::extend_ch, font::load_font, trim_arg, font::load)
      (font::load_desc)
    * src/libs/libgroff/searchpath.cpp (search_path::search_path)
      (search_path::open_file, search_path::open_file_cautious):
    * src/preproc/eqn/main.cpp (main):
    * src/preproc/html/pre-html.cpp (get_resolution, get_image_generator):
    
    * src/roff/troff/input.cpp (file_iterator::set_location, next_file)
      (do_open, close_request, do_write_request, write_macro_request,
      (transparent_file, open_macro_package, process_macro_package_argument)
      (process_startup_file, do_macro_source, process_input_file): Annotate
      null pointers with `nullptr` comment to ease any future transition to
      C++11, which defines it as a keyword.
---
 src/libs/libgroff/font.cpp       | 161 ++++++++++++++++++++-------------------
 src/libs/libgroff/searchpath.cpp |  47 ++++++------
 src/preproc/eqn/main.cpp         |   2 +-
 src/preproc/html/pre-html.cpp    |   4 +-
 src/roff/troff/input.cpp         |  28 +++----
 5 files changed, 124 insertions(+), 118 deletions(-)

diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp
index 591da14f7..4ec4f19db 100644
--- a/src/libs/libgroff/font.cpp
+++ b/src/libs/libgroff/font.cpp
@@ -55,7 +55,8 @@ struct font_kern_list {
   int amount;
   font_kern_list *next;
 
-  font_kern_list(glyph *, glyph *, int, font_kern_list * = 0);
+  font_kern_list(glyph *, glyph *, int,
+                font_kern_list * = 0 /* nullptr */);
 };
 
 struct font_widths_cache {
@@ -63,7 +64,7 @@ struct font_widths_cache {
   int point_size;
   int *width;
 
-  font_widths_cache(int, int, font_widths_cache * = 0);
+  font_widths_cache(int, int, font_widths_cache * = 0 /* nullptr */);
   ~font_widths_cache();
 };
 
@@ -91,7 +92,8 @@ struct text_file {
 };
 
 text_file::text_file(FILE *p, char *s) : fp(p), path(s), lineno(0),
-  linebufsize(128), recognize_comments(true), silent(false), buf(0)
+  linebufsize(128), recognize_comments(true), silent(false),
+  buf(0 /* nullptr */)
 {
 }
 
@@ -105,9 +107,9 @@ text_file::~text_file()
 
 bool text_file::next_line()
 {
-  if (0 == fp)
+  if (0 /* nullptr */ == fp)
     return false;
-  if (0 == buf)
+  if (0 /* nullptr */ == buf)
     buf = new char[linebufsize];
   for (;;) {
     lineno++;
@@ -137,7 +139,7 @@ bool text_file::next_line()
     char *ptr = buf;
     while (csspace(*ptr))
       ptr++;
-    if (*ptr != 0 && (!recognize_comments || *ptr != '#'))
+    if (*ptr != 0 /* nullptr */ && (!recognize_comments || *ptr != '#'))
       return true;
   }
   return false;
@@ -164,7 +166,7 @@ void text_file::fatal(const char *format,
 int glyph_to_unicode(glyph *g)
 {
   const char *nm = glyph_to_name(g);
-  if (nm != 0) {
+  if (nm != 0 /* nullptr */) {
     // ASCII character?
     if (nm[0] == 'c' && nm[1] == 'h' && nm[2] == 'a' && nm[3] == 'r'
        && (nm[4] >= '0' && nm[4] <= '9')) {
@@ -195,7 +197,8 @@ int glyph_to_unicode(glyph *g)
     }
     // groff glyphs that map to Unicode?
     const char *unicode = glyph_name_to_unicode(nm);
-    if ((unicode != 0) && (strchr(unicode, '_') == 0)) {
+    if ((unicode != 0 /* nullptr */)
+       && (strchr(unicode, '_') == 0 /* nullptr */)) {
       char *ignore;
       return (int)strtol(unicode, &ignore, 16);
     }
@@ -205,10 +208,12 @@ int glyph_to_unicode(glyph *g)
 
 /* font functions */
 
-font::font(const char *s) : ligatures(0), kern_hash_table(0),
-  space_width(0), special(false), internalname(0), slant(0.0), zoom(0),
-  ch_index(0), nindices(0), ch(0), ch_used(0), ch_size(0),
-  widths_cache(0)
+font::font(const char *s) : ligatures(0),
+  kern_hash_table(0 /* nullptr */),
+  space_width(0), special(false), internalname(0 /* nullptr */),
+  slant(0.0), zoom(0), ch_index(0 /* nullptr */), nindices(0),
+  ch(0 /* nullptr */), ch_used(0), ch_size(0),
+  widths_cache(0 /* nullptr */)
 {
   name = new char[strlen(s) + 1];
   strcpy(name, s);
@@ -644,7 +649,7 @@ void font::alloc_ch_index(int idx)
 
 void font::extend_ch()
 {
-  if (0 == ch)
+  if (0 /* nullptr */ == ch)
     ch = new font_char_metric[ch_size = 16];
   else {
     int old_ch_size = ch_size;
@@ -708,15 +713,15 @@ font *font::load_font(const char *s, bool 
load_header_only)
   font *f = new font(s);
   if (!f->load(load_header_only)) {
     delete f;
-    return 0;
+    return 0 /* nullptr */;
   }
   return f;
 }
 
 static char *trim_arg(char *p)
 {
-  if (0 == p)
-    return 0;
+  if (0 /* nullptr */ == p)
+    return 0 /* nullptr */;
   while (csspace(*p))
     p++;
   char *q = strchr(p, '\0');
@@ -762,7 +767,7 @@ again:
       }
     if (attempt_file_open) {
       FILE *fp = fopen(p, "r");
-      if (fp != 0) {
+      if (fp != 0 /* nullptr */) {
        if (fgets(line, 254, fp)) {
          // Don't recurse on file names.
          attempt_file_open = false;
@@ -784,17 +789,17 @@ bool font::load(bool load_header_only)
 {
   char *path;
   FILE *fp = open_file(name, &path);
-  if (0 == fp)
+  if (0 /* nullptr */ == fp)
     return false;
   text_file t(fp, path);
   t.silent = load_header_only;
-  char *p = 0;
+  char *p = 0 /* nullptr */;
   bool saw_name_directive = false;
   while (t.next_line()) {
     p = strtok(t.buf, WS);
     if (strcmp(p, "name") == 0) {
-      p = strtok(0, WS);
-      if (0 == p) {
+      p = strtok(0 /* nullptr */, WS);
+      if (0 /* nullptr */ == p) {
        t.error("'name' directive requires an argument");
        return false;
       }
@@ -806,9 +811,9 @@ bool font::load(bool load_header_only)
       saw_name_directive = true;
     }
     else if (strcmp(p, "spacewidth") == 0) {
-      p = strtok(0, WS);
+      p = strtok(0 /* nullptr */, WS);
       int n;
-      if (0 == p) {
+      if (0 /* nullptr */ == p) {
        t.error("missing argument to 'spacewidth' directive");
        return false;
       }
@@ -823,9 +828,9 @@ bool font::load(bool load_header_only)
       space_width = n;
     }
     else if (strcmp(p, "slant") == 0) {
-      p = strtok(0, WS);
+      p = strtok(0 /* nullptr */, WS);
       double n;
-      if (0 == p) {
+      if (0 /* nullptr */ == p) {
        t.error("missing argument to 'slant' directive");
        return false;
       }
@@ -841,8 +846,8 @@ bool font::load(bool load_header_only)
     }
     else if (strcmp(p, "ligatures") == 0) {
       for (;;) {
-       p = strtok(0, WS);
-       if (0 == p || strcmp(p, "0") == 0)
+       p = strtok(0 /* nullptr */, WS);
+       if (0 /* nullptr */ == p || strcmp(p, "0") == 0)
          break;
        if (strcmp(p, "ff") == 0)
          ligatures |= LIG_ff;
@@ -861,8 +866,8 @@ bool font::load(bool load_header_only)
       }
     }
     else if (strcmp(p, "internalname") == 0) {
-      p = strtok(0, WS);
-      if (0 == p) {
+      p = strtok(0 /* nullptr */, WS);
+      if (0 /* nullptr */ == p) {
        t.error("missing argument to 'internalname' directive");
        return false;
       }
@@ -874,7 +879,7 @@ bool font::load(bool load_header_only)
     }
     else if (strcmp(p, "kernpairs") != 0 && strcmp(p, "charset") != 0) {
       char *directive = p;
-      p = strtok(0, "\n");
+      p = strtok(0 /* nullptr */, "\n");
       handle_unknown_font_command(directive, trim_arg(p), t.path,
                                  t.lineno);
     }
@@ -890,19 +895,19 @@ bool font::load(bool load_header_only)
        return true;
       for (;;) {
        if (!t.next_line()) {
-         directive = 0;
+         directive = 0 /* nullptr */;
          break;
        }
        char *c1 = strtok(t.buf, WS);
-       if (0 == c1)
+       if (0 /* nullptr */ == c1)
          continue;
-       char *c2 = strtok(0, WS);
-       if (0 == c2) {
+       char *c2 = strtok(0 /* nullptr */, WS);
+       if (0 /* nullptr */ == c2) {
          directive = c1;
          break;
        }
-       p = strtok(0, WS);
-       if (0 == p) {
+       p = strtok(0 /* nullptr */, WS);
+       if (0 /* nullptr */ == p) {
          t.error("missing kern amount for kerning pair '%1 %2'", c1,
                  c2);
          return false;
@@ -922,21 +927,21 @@ bool font::load(bool load_header_only)
       if (load_header_only)
        return true;
       saw_charset_directive = true;
-      glyph *last_glyph = 0;
+      glyph *last_glyph = 0 /* nullptr */;
       for (;;) {
        if (!t.next_line()) {
-         directive = 0;
+         directive = 0 /* nullptr */;
          break;
        }
        char *nm = strtok(t.buf, WS);
-       assert(nm != 0);
-       p = strtok(0, WS);
-       if (0 == p) {
+       assert(nm != 0 /* nullptr */);
+       p = strtok(0 /* nullptr */, WS);
+       if (0 /* nullptr */ == p) {
          directive = nm;
          break;
        }
        if (p[0] == '"') {
-         if (0 == last_glyph) {
+         if (0 /* nullptr */ == last_glyph) {
            t.error("the first entry ('%1') in 'charset' subsection"
                    " cannot be an alias", nm);
            return false;
@@ -965,8 +970,8 @@ bool font::load(bool load_header_only)
            t.error("missing or invalid width for glyph '%1'", nm);
            return false;
          }
-         p = strtok(0, WS);
-         if (0 == p) {
+         p = strtok(0 /* nullptr */, WS);
+         if (0 /* nullptr */ == p) {
            t.error("missing character type for '%1'", nm);
            return false;
          }
@@ -981,8 +986,8 @@ bool font::load(bool load_header_only)
            return false;
          }
          metric.type = type;
-         p = strtok(0, WS);
-         if (0 == p) {
+         p = strtok(0 /* nullptr */, WS);
+         if (0 /* nullptr */ == p) {
            t.error("missing code for '%1'", nm);
            return false;
          }
@@ -997,8 +1002,8 @@ bool font::load(bool load_header_only)
            if (w > 1)
              metric.width *= w;
          }
-         p = strtok(0, WS);
-         if ((0 == p) || (strcmp(p, "--") == 0)) {
+         p = strtok(0 /* nullptr */, WS);
+         if ((0 /* nullptr */ == p) || (strcmp(p, "--") == 0)) {
            metric.special_device_coding = 0;
          }
          else {
@@ -1017,7 +1022,7 @@ bool font::load(bool load_header_only)
          }
        }
       }
-      if (0 == last_glyph) {
+      if (0 /* nullptr */ == last_glyph) {
        t.error("no glyphs defined in font description");
        return false;
       }
@@ -1073,12 +1078,12 @@ const char *font::load_desc()
   int nfonts = 0;
   char *path;
   FILE *fp = open_file("DESC", &path);
-  if (0 == fp)
+  if (0 /* nullptr */ == fp)
     return 0 /* nullptr */;
   text_file t(fp, path);
   while (t.next_line()) {
     char *p = strtok(t.buf, WS);
-    assert(p != 0);
+    assert(p != 0 /* nullptr */);
     bool numeric_directive_found = false;
     unsigned int idx;
     for (idx = 0; !numeric_directive_found
@@ -1086,8 +1091,8 @@ const char *font::load_desc()
       if (strcmp(table[idx].numeric_directive, p) == 0)
        numeric_directive_found = true;
     if (numeric_directive_found) {
-      char *q = strtok(0, WS);
-      if (0 == q) {
+      char *q = strtok(0 /* nullptr */, WS);
+      if (0 /* nullptr */ == q) {
        t.error("missing value for directive '%1'", p);
        return 0 /* nullptr */;
       }
@@ -1111,8 +1116,8 @@ const char *font::load_desc()
       *(table[idx-1].ptr) = val;
     }
     else if (strcmp("family", p) == 0) {
-      p = strtok(0, WS);
-      if (0 == p) {
+      p = strtok(0 /* nullptr */, WS);
+      if (0 /* nullptr */ == p) {
        t.error("'family' directive requires an argument");
        return 0 /* nullptr */;
       }
@@ -1121,8 +1126,8 @@ const char *font::load_desc()
       family = tem;
     }
     else if (strcmp("fonts", p) == 0) {
-      p = strtok(0, WS);
-      if (0 == p) {
+      p = strtok(0 /* nullptr */, WS);
+      if (0 /* nullptr */ == p) {
        t.error("'fonts' directive requires arguments");
        return 0 /* nullptr */;
       }
@@ -1133,8 +1138,8 @@ const char *font::load_desc()
       }
       font_name_table = (const char **)new char *[nfonts+1];
       for (int i = 0; i < nfonts; i++) {
-       p = strtok(0, WS);
-       while (0 == p) {
+       p = strtok(0 /* nullptr */, WS);
+       while (0 /* nullptr */ == p) {
          if (!t.next_line()) {
            t.error("unexpected end of file while reading font list");
            return 0 /* nullptr */;
@@ -1145,28 +1150,28 @@ const char *font::load_desc()
        strcpy(temp, p);
        font_name_table[i] = temp;
       }
-      p = strtok(0, WS);
-      if (p != 0) {
+      p = strtok(0 /* nullptr */, WS);
+      if (p != 0 /* nullptr */) {
        t.error("font count does not match declared number of fonts"
                " ('%1')", nfonts);
        return 0 /* nullptr */;
       }
-      font_name_table[nfonts] = 0;
+      font_name_table[nfonts] = 0 /* nullptr */;
     }
     else if (strcmp("papersize", p) == 0) {
-      if (0 == res) {
+      if (0 /* nullptr */ == res) {
        t.error("'res' directive must precede 'papersize' in device"
                " description file");
        return 0 /* nullptr */;
       }
-      p = strtok(0, WS);
-      if (0 == p) {
+      p = strtok(0 /* nullptr */, WS);
+      if (0 /* nullptr */ == p) {
        t.error("'papersize' directive requires an argument");
        return 0 /* nullptr */;
       }
       bool found_paper = false;
       char *savedp = strdup(p);
-      if (0 == savedp)
+      if (0 /* nullptr */ == savedp)
        t.fatal("memory allocation failure while processing 'papersize'"
                " directive");
       while (p) {
@@ -1178,9 +1183,9 @@ const char *font::load_desc()
          found_paper = true;
          break;
        }
-       p = strtok(0, WS);
+       p = strtok(0 /* nullptr */, WS);
       }
-      assert(savedp != 0);
+      assert(savedp != 0 /* nullptr */);
       if (!found_paper) {
        t.error("unable to determine a paper format from '%1'", savedp);
        free(savedp);
@@ -1197,8 +1202,8 @@ const char *font::load_desc()
       sizes = new int[n];
       int i = 0;
       for (;;) {
-       p = strtok(0, WS);
-       while (0 == p) {
+       p = strtok(0 /* nullptr */, WS);
+       while (0 /* nullptr */ == p) {
          if (!t.next_line()) {
            t.error("list of sizes must be terminated by '0'");
            return 0 /* nullptr */;
@@ -1243,8 +1248,8 @@ const char *font::load_desc()
        style_table[j] = 0;
       int i = 0;
       for (;;) {
-       p = strtok(0, WS);
-       if (0 == p)
+       p = strtok(0 /* nullptr */, WS);
+       if (0 /* nullptr */ == p)
          break;
        // leave room for terminating 0
        if (i + 1 >= style_table_size) {
@@ -1269,8 +1274,8 @@ const char *font::load_desc()
     else if (strcmp("unicode", p) == 0)
       is_unicode = true;
     else if (strcmp("image_generator", p) == 0) {
-      p = strtok(0, WS);
-      if (0 == p) {
+      p = strtok(0 /* nullptr */, WS);
+      if (0 /* nullptr */ == p) {
        t.error("'image_generator' directive requires an argument");
        return 0 /* nullptr */;
       }
@@ -1280,13 +1285,13 @@ const char *font::load_desc()
       break;
     else if (unknown_desc_command_handler) {
       char *directive = p;
-      p = strtok(0, "\n");
+      p = strtok(0 /* nullptr */, "\n");
       (*unknown_desc_command_handler)(directive, trim_arg(p), t.path,
                                      t.lineno);
     }
   }
   t.lineno = 0;
-  if (0 == res) {
+  if (0 /* nullptr */ == res) {
     t.error("device description file missing 'res' directive");
     return 0 /* nullptr */;
   }
@@ -1294,11 +1299,11 @@ const char *font::load_desc()
     t.error("device description file missing 'unitwidth' directive");
     return 0 /* nullptr */;
   }
-  if (0 == font_name_table) {
+  if (0 /* nullptr */ == font_name_table) {
     t.error("device description file missing 'fonts' directive");
     return 0 /* nullptr */;
   }
-  if (0 == sizes) {
+  if (0 /* nullptr */ == sizes) {
     t.error("device description file missing 'sizes' directive");
     return 0 /* nullptr */;
   }
diff --git a/src/libs/libgroff/searchpath.cpp b/src/libs/libgroff/searchpath.cpp
index 0bc03ac68..0fc465b28 100644
--- a/src/libs/libgroff/searchpath.cpp
+++ b/src/libs/libgroff/searchpath.cpp
@@ -38,11 +38,11 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 search_path::search_path(const char *envvar, const char *standard,
                         int add_home, int add_current)
 {
-  char *home = 0;
+  char *home = 0 /* nullptr */;
   if (add_home)
     home = getenv("HOME");
-  char *e = 0;
-  if (envvar != 0)
+  char *e = 0 /* nullptr */;
+  if (envvar != 0 /* nullptr */)
     e = getenv(envvar);
   dirs = new char[((e && *e) ? strlen(e) + 1 : 0)
                  + (add_current ? 1 + 1 : 0)
@@ -97,22 +97,22 @@ void search_path::command_line_dir(const char *s)
 
 FILE *search_path::open_file(const char *name, char **pathp)
 {
-  assert(name != 0);
+  assert(name != 0 /* nullptr */);
   if (IS_ABSOLUTE(name) || *dirs == '\0') {
     FILE *fp = fopen(name, "r");
-    if (fp != 0) {
-      if (pathp != 0)
+    if (fp != 0 /* nullptr */) {
+      if (pathp != 0 /* nullptr */)
        *pathp = strsave(name);
       return fp;
     }
     else
-      return 0;
+      return 0 /* nullptr */;
   }
   unsigned namelen = strlen(name);
   char *p = dirs;
   for (;;) {
     char *end = strchr(p, PATH_SEP_CHAR);
-    if (0 == end)
+    if (0 /* nullptr */ == end)
       end = strchr(p, '\0');
     int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0;
     char *origpath = new char[(end - p) + need_slash + namelen + 1];
@@ -130,8 +130,8 @@ FILE *search_path::open_file(const char *name, char **pathp)
 #endif
     FILE *fp = fopen(path, "r");
     int err = errno;
-    if (fp != 0) {
-      if (pathp != 0)
+    if (fp != 0 /* nullptr */) {
+      if (pathp != 0 /* nullptr */)
        *pathp = path;
       else {
        free(path);
@@ -145,37 +145,38 @@ FILE *search_path::open_file(const char *name, char 
**pathp)
       break;
     p = end + 1;
   }
-  return 0;
+  return 0 /* nullptr */;
 }
 
 FILE *search_path::open_file_cautious(const char *name, char **pathp,
                                      const char *mode)
 {
-  if (0 == mode)
+  if (0 /* nullptr */ == mode)
     mode = "r";
-  bool reading = (strchr(mode, 'r') != 0);
-  if (0 == name || strcmp(name, "-") == 0) {
+  bool reading = (strchr(mode, 'r') != 0 /* nullptr */);
+  if (0 /* nullptr */ == name || strcmp(name, "-") == 0) {
     if (pathp != 0)
       *pathp = strsave(reading ? "stdin" : "stdout");
     return (reading ? stdin : stdout);
   }
   if (!reading || IS_ABSOLUTE(name) || *dirs == '\0') {
     FILE *fp = fopen(name, mode);
-    if (fp != 0) {
-      if (pathp != 0)
+    if (fp != 0 /* nullptr */) {
+      if (pathp != 0 /* nullptr */)
        *pathp = strsave(name);
       return fp;
     }
     else
-      return 0;
+      return 0 /* nullptr */;
   }
   unsigned namelen = strlen(name);
   char *p = dirs;
   for (;;) {
     char *end = strchr(p, PATH_SEP_CHAR);
-    if (0 == end)
+    if (0 /* nullptr */ == end)
       end = strchr(p, '\0');
-    int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0;
+    int need_slash = (end > p
+                     && strchr(DIR_SEPS, end[-1]) == 0 /* nullptr */);
     char *origpath = new char[(end - p) + need_slash + namelen + 1];
     memcpy(origpath, p, end - p);
     if (need_slash)
@@ -191,8 +192,8 @@ FILE *search_path::open_file_cautious(const char *name, 
char **pathp,
 #endif
     FILE *fp = fopen(path, mode);
     int err = errno;
-    if (fp != 0) {
-      if (pathp != 0)
+    if (fp != 0 /* nullptr */) {
+      if (pathp != 0 /* nullptr */)
        *pathp = path;
       else {
        free(path);
@@ -203,13 +204,13 @@ FILE *search_path::open_file_cautious(const char *name, 
char **pathp,
     free(path);
     errno = err;
     if (err != ENOENT)
-      return 0;
+      return 0 /* nullptr */;
     if (*end == '\0')
       break;
     p = end + 1;
   }
   errno = ENOENT;
-  return 0;
+  return 0 /* nullptr */;
 }
 
 // Local Variables:
diff --git a/src/preproc/eqn/main.cpp b/src/preproc/eqn/main.cpp
index b7eed4b6b..4beebd1c5 100644
--- a/src/preproc/eqn/main.cpp
+++ b/src/preproc/eqn/main.cpp
@@ -447,7 +447,7 @@ int main(int argc, char **argv)
   if (want_startup_file) {
     char *path;
     FILE *fp = config_macro_path.open_file(STARTUP_FILE, &path);
-    if (fp != 0) {
+    if (fp != 0 /* nullptr */) {
       do_file(fp, path);
       if (fclose(fp) < 0)
        fatal("unable to close '%1': %2", STARTUP_FILE,
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index 751cba78e..c851c6158 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -310,7 +310,7 @@ static unsigned int get_resolution(void)
   FILE *f;
   unsigned int res = 0;
   f = font_path.open_file(devps_desc, &pathp);
-  if (0 == f)
+  if (0 /* nullptr */ == f)
     fatal("cannot open file '%1'", devps_desc);
   free(pathp);
   // XXX: We should break out of this loop if we hit a "charset" line.
@@ -336,7 +336,7 @@ static char *get_image_generator(void)
   const char keyword[] = "image_generator";
   const size_t keyword_len = strlen(keyword);
   f = font_path.open_file(devhtml_desc, &pathp);
-  if (0 == f)
+  if (0 /* nullptr */ == f)
     fatal("cannot open file '%1'", devhtml_desc);
   free(pathp);
   // XXX: We should break out of this loop if we hit a "charset" line.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index b6a400cd4..279669ea4 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -512,7 +512,7 @@ void file_iterator::backtrace()
 
 bool file_iterator::set_location(const char *f, int ln)
 {
-  if (f != 0)
+  if (f != 0 /* nullptr */)
     filename = f;
   lineno = ln;
   return true;
@@ -898,7 +898,7 @@ void next_file()
   else {
     errno = 0;
     FILE *fp = include_search_path.open_file_cautious(nm.contents());
-    if (0 == fp)
+    if (0 /* nullptr */ == fp)
       error("can't open '%1': %2", nm.contents(), strerror(errno));
     else
       input_stack::next_file(fp, nm.contents());
@@ -6973,7 +6973,7 @@ static void do_open(bool append)
     if (!filename.is_null()) {
       errno = 0;
       FILE *fp = fopen(filename.contents(), append ? "a" : "w");
-      if (0 == fp) {
+      if (0 /* nullptr */ == fp) {
        error("unable to open file '%1' for %2: %3",
              filename.contents(),
              append ? "appending" : "writing",
@@ -7014,7 +7014,7 @@ static void close_request()
   symbol stream = get_name(true /* required */);
   if (!stream.is_null()) {
     FILE *fp = (FILE *)stream_dictionary.remove(stream);
-    if (0 == fp)
+    if (0 /* nullptr */ == fp)
       error("cannot close nonexistent stream '%1'", stream.contents());
     else {
       int status = fclose(fp);
@@ -7036,7 +7036,7 @@ void do_write_request(int newline)
     return;
   }
   FILE *fp = (FILE *)stream_dictionary.lookup(stream);
-  if (0 == fp) {
+  if (0 /* nullptr */ == fp) {
     error("no stream named '%1'", stream.contents());
     skip_line();
     return;
@@ -7072,7 +7072,7 @@ void write_macro_request()
     return;
   }
   FILE *fp = (FILE *)stream_dictionary.lookup(stream);
-  if (0 == fp) {
+  if (0 /* nullptr */ == fp) {
     error("no stream named '%1'", stream.contents());
     skip_line();
     return;
@@ -7926,7 +7926,7 @@ void transparent_file()
   if (!filename.is_null()) {
     errno = 0;
     FILE *fp = include_search_path.open_file_cautious(filename.contents());
-    if (0 == fp)
+    if (0 /* nullptr */ == fp)
       error("can't open '%1': %2", filename.contents(), strerror(errno));
     else {
       int bol = 1;
@@ -8028,15 +8028,15 @@ static FILE *open_macro_package(const char *mac, char 
**path)
   strcpy(s1, mac);
   strcat(s1, MACRO_POSTFIX);
   FILE *fp = mac_path->open_file(s1, path);
-  if ((0 == fp) && (ENOENT != errno))
+  if ((0 /* nullptr */ == fp) && (ENOENT != errno))
     error("unable to open macro file '%1': %2", s1, strerror(errno));
   delete[] s1;
-  if (0 == fp) {
+  if (0 /* nullptr */ == fp) {
     char *s2 = new char[strlen(mac) + strlen(MACRO_PREFIX) + 1];
     strcpy(s2, MACRO_PREFIX);
     strcat(s2, mac);
     fp = mac_path->open_file(s2, path);
-    if ((0 == fp) && (ENOENT != errno))
+    if ((0 /* nullptr */ == fp) && (ENOENT != errno))
       error("unable to open macro file '%1': %2", s2, strerror(errno));
     delete[] s2;
   }
@@ -8047,7 +8047,7 @@ static void process_macro_package_argument(const char 
*mac)
 {
   char *path;
   FILE *fp = open_macro_package(mac, &path);
-  if (0 == fp)
+  if (0 /* nullptr */ == fp)
     fatal("unable to open macro file for -m argument '%1'", mac);
   const char *s = symbol(path).contents();
   free(path);
@@ -8062,7 +8062,7 @@ static void process_startup_file(const char *filename)
   search_path *orig_mac_path = mac_path;
   mac_path = &config_macro_path;
   FILE *fp = mac_path->open_file(filename, &path);
-  if (fp != 0) {
+  if (fp != 0 /* nullptr */) {
     input_stack::push(new file_iterator(fp, symbol(path).contents()));
     free(path);
     tok.next();
@@ -8081,7 +8081,7 @@ void do_macro_source(bool quietly)
       tok.next();
     char *path;
     FILE *fp = mac_path->open_file(nm.contents(), &path);
-    if (fp != 0) {
+    if (fp != 0 /* nullptr */) {
       input_stack::push(new file_iterator(fp, symbol(path).contents()));
       free(path);
     }
@@ -8120,7 +8120,7 @@ static void process_input_file(const char *name)
   else {
     errno = 0;
     fp = include_search_path.open_file_cautious(name);
-    if (0 == fp)
+    if (0 /* nullptr */ == fp)
       fatal("can't open '%1': %2", name, strerror(errno));
   }
   input_stack::push(new file_iterator(fp, name));

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

Reply via email to