gbranden pushed a commit to branch master
in repository groff.

commit cb5187091eae3239264d66a3ea1c3dca7f5fc287
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon May 25 01:53:00 2026 -0500

    [tfmtodit]: Fix code style nits. (3/6)
    
    * src/utils/tfmtodit/tfmtodit.cpp (tfm:load): Explicitly compare
      variables of pointer type to null pointer literal instead of letting
      them pun down to Booleans.  Arrange equality comparisons to avoid
      inadvertent lvalue assignment.
---
 ChangeLog                       |  3 ++-
 src/utils/tfmtodit/tfmtodit.cpp | 12 ++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80b7f2b64..62ec5c7d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,8 @@
        * src/utils/tfmtodit/tfmtodit.cpp (tfm:load): Fix code style
        nits.  Parenthesize formally complex expressions.  Explicitly
        compare variables of pointer type to null pointer literal
-       instead of letting them pun down to Booleans.
+       instead of letting them pun down to Booleans.  Arrange equality
+       comparisons to avoid inadvertent lvalue assignment.
 
 2026-05-25  G. Branden Robinson <[email protected]>
 
diff --git a/src/utils/tfmtodit/tfmtodit.cpp b/src/utils/tfmtodit/tfmtodit.cpp
index a603f42a5..a2b9c261b 100644
--- a/src/utils/tfmtodit/tfmtodit.cpp
+++ b/src/utils/tfmtodit/tfmtodit.cpp
@@ -286,7 +286,7 @@ int tfm::load(const char *file)
 {
   errno = 0;
   FILE *fp = fopen(file, FOPEN_RB);
-  if (!fp) {
+  if (0 /* nullptr */ == fp) {
     error("can't open '%1': %2", file, strerror(errno));
     return 0;
   }
@@ -427,7 +427,7 @@ int gf::load(const char *file)
   const int gf_id_byte = 131;
   errno = 0;
   FILE *fp = fopen(file, FOPEN_RB);
-  if (!fp) {
+  if (0 /* nullptr */ == fp) {
     error("can't open '%1': %2", file, strerror(errno));
     return 0;
   }
@@ -614,7 +614,7 @@ int read_map(const char *file, char_list **table)
 {
   errno = 0;
   FILE *fp = fopen(file, "r");
-  if (!fp) {
+  if (0 /* nullptr */ == fp) {
     error("can't open '%1': %2", file, strerror(errno));
     return 0;
   }
@@ -630,7 +630,7 @@ int read_map(const char *file, char_list **table)
     if (*ptr == '\0' || *ptr == '#')
       continue;
     ptr = strtok(ptr, " \n\t");
-    if (!ptr)
+    if (0 /* nullptr */ == ptr)
       continue;
     int n;
     if (sscanf(ptr, "%d", &n) != 1) {
@@ -643,8 +643,8 @@ int read_map(const char *file, char_list **table)
       fclose(fp);
       return 0;
     }
-    ptr = strtok(0, " \n\t");
-    if (!ptr) {
+    ptr = strtok(0 /* nullptr */, " \n\t");
+    if (0 /* nullptr */ == ptr) {
       error("%1:%2: missing names", file, lineno);
       fclose(fp);
       return 0;

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

Reply via email to