groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 32/60: [troff]: Fix code style nits (node.cpp).


From: G. Branden Robinson
Subject: [groff] 32/60: [troff]: Fix code style nits (node.cpp).
Date: Wed, 11 Sep 2024 03:38:32 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 827a95630fe0201e638fea3044591228776360b0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Sep 9 17:02:55 2024 -0500

    [troff]: Fix code style nits (node.cpp).
    
    * src/roff/troff/node.cpp (troff_output_file::fill_color): Explicitly
      compare variable of pointer type to null pointer literal instead of
      letting it pun down to a Boolean.
    
      (glyph_node::add_self)
      (dbreak_node::merge_glyph_node)
      (kern_pair_node::merge_glyph_node):
      (kern_pair_node::add_discretionary_hyphen): Reorder equality
      comparisons to avoid inadvertent lvalue assignment.
    
      (kern_pair_node::merge_glyph_node): Chain assignments as is done in
      the rest of this file.
---
 ChangeLog               | 13 +++++++++++++
 src/roff/troff/node.cpp | 14 +++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 834b65d18..4170be7b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-09-09  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/node.cpp (troff_output_file::fill_color):
+       Explicitly compare variable of pointer type to null pointer
+       literal instead of letting it pun down to a Boolean.
+       (glyph_node::add_self)
+       (dbreak_node::merge_glyph_node):
+       (kern_pair_node::merge_glyph_node):
+       (kern_pair_node::add_discretionary_hyphen): Reorder equality
+       comparisons to avoid inadvertent lvalue assignment.
+       (kern_pair_node::merge_glyph_node): Chain assignments as is done
+       in the rest of this file.
+
 2024-09-08  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/env.cpp (print_env): Improve environment
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 06c41e7e6..58c4ab0e2 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -1268,7 +1268,7 @@ void troff_output_file::set_font(tfont *tf)
 
 void troff_output_file::fill_color(color *col)
 {
-  if (!col || current_fill_color == col)
+  if ((0 /* nullptr */ == col) || current_fill_color == col)
     return;
   current_fill_color = col;
   if (!want_color_output)
@@ -2067,7 +2067,8 @@ node *glyph_node::add_self(node *n, hyphen_list **p)
   assert(ci->get_hyphenation_code() == (*p)->hyphenation_code);
   next = 0 /* nullptr */;
   node *nn;
-  if (n == 0 || (nn = n->merge_glyph_node(this)) == 0) {
+  if ((0 /* nullptr */ == n) ||
+      (0 /* nullptr */ == (nn = n->merge_glyph_node(this)))) {
     next = n;
     nn = this;
   }
@@ -2297,7 +2298,7 @@ node *dbreak_node::merge_glyph_node(glyph_node *gn)
   glyph_node *gn2 = (glyph_node *)gn->copy();
   node *new_none = none ? none->merge_glyph_node(gn) : 0 /* nullptr */;
   node *new_post = post ? post->merge_glyph_node(gn2) : 0 /* nullptr */;
-  if (new_none == 0 && new_post == 0) {
+  if ((0 /* nullptr */ == new_none) && (0 /* nullptr */ == new_post)) {
     delete gn2;
     return 0 /* nullptr */;
   }
@@ -2319,14 +2320,13 @@ node *dbreak_node::merge_glyph_node(glyph_node *gn)
 node *kern_pair_node::merge_glyph_node(glyph_node *gn)
 {
   node *nd = n2->merge_glyph_node(gn);
-  if (nd == 0 /* nullptr */)
+  if (0 /* nullptr */ == nd)
     return 0 /* nullptr */;
   n2 = nd;
   nd = n2->merge_self(n1);
   if (nd) {
     nd->next = next;
-    n1 = 0 /* nullptr */;
-    n2 = 0 /* nullptr */;
+    n1 = n2 = 0 /* nullptr */;
     delete this;
     return nd;
   }
@@ -2367,7 +2367,7 @@ node *kern_pair_node::add_discretionary_hyphen()
       glyph_node *gn = new glyph_node(soft_hyphen_char, tf, gcol, fcol,
                                      state, div_nest_level);
       node *nn = n->merge_glyph_node(gn);
-      if (nn == 0 /* nullptr */) {
+      if (0 /* nullptr */ == nn) {
        gn->next = n;
        nn = gn;
       }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]