gbranden pushed a commit to branch master
in repository groff.

commit 717c5e45e6ed9c53a1199addd8b1c6a8afb75969
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Nov 23 14:44:55 2025 -0600

    src/roff/troff/env.cpp: Fix code style nits.
    
    * src/roff/troff/env.cpp (environment::make_tab_node): Parenthesize
      formally complex expression.
    
      (environment::make_tab_node, environment::advance_to_tab_stop):
      Explicitly compare value of pointer type to null pointer literal
      instead of letting it pun down to a Boolean.  Revise logic for less
      cleverness (gratuitous use of ternary operator on pointer).
    
    Also annotate null pointers with `nullptr` comment to ease any future
    transition to C++11, which defines it as a keyword.
---
 ChangeLog              | 10 ++++++++++
 src/roff/troff/env.cpp | 14 ++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0c309199f..57a16cb80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-11-23  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/env.cpp: Fix code style nits.
+       (environment::make_tab_node): Parenthesize formally complex
+       expression.
+       (environment::make_tab_node, environment::advance_to_tab_stop):
+       Explicitly compare value of pointer type to null pointer literal
+       instead of letting it pun down to a Boolean.  Revise logic for
+       less cleverness (gratuitous use of ternary operator on pointer).
+
 2025-11-23  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/env.cpp: Trivially refactor.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 2270a84f0..8b1bb0c9e 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -885,7 +885,7 @@ environment::environment(const environment *e)
   underline_spaces(false),
   input_trap_count(-1),
   continued_input_trap(false),
-  line(0) /* nullptr */,
+  line(0 /* nullptr */),
   prev_text_length(e->prev_text_length),
   width_total(0),
   space_total(0),
@@ -3135,15 +3135,15 @@ void environment::wrap_up_tab()
 
 node *environment::make_tab_node(hunits d, node *next)
 {
-  if (leader_node != 0 && d < 0) {
+  if ((leader_node != 0 /* nullptr */) && (d < 0)) {
     error("motion generated by leader cannot be negative");
     delete leader_node;
-    leader_node = 0;
+    leader_node = 0 /* nullptr */;
   }
-  if (!leader_node)
+  if (0 /* nullptr */ == leader_node)
     return new hmotion_node(d, 1, 0, get_fill_color(), next);
   node *nd = new hline_node(d, leader_node, next);
-  leader_node = 0;
+  leader_node = 0 /* nullptr */;
   return nd;
 }
 
@@ -3155,7 +3155,9 @@ void environment::advance_to_tab_stop(bool use_leader)
     wrap_up_tab();
   charinfo *ci = use_leader ? leader_char : tab_char;
   delete leader_node;
-  leader_node = ci ? make_char_node(ci) : 0;
+  leader_node = 0 /* nullptr */;
+  if (ci != 0 /* nullptr */)
+    leader_node = make_char_node(ci);
   tab_type t = distance_to_next_tab(&d, &absolute);
   switch (t) {
   case TAB_NONE:

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

Reply via email to