groff-commit
[Top][All Lists]
Advanced

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

[groff] 11/35: [troff]: Refactor.


From: G. Branden Robinson
Subject: [groff] 11/35: [troff]: Refactor.
Date: Fri, 15 Jul 2022 23:11:57 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit bca4506f36eeda9640c4fcc01b66444e7291b508
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Jul 8 18:10:43 2022 -0500

    [troff]: Refactor.
    
    * src/roff/troff/node.cpp (get_register, get_string): Reorder null
      pointer inequality comparisons; they don't need to be in a funny order
      because it's pretty hard to mistype `!=` as an assignment operator.
      Annotate them as null pointers to ease any future migration to ISO
      C++11.  Use primitive type constructor instead of C-style cast
      operator; this seems more idiomatic.
---
 ChangeLog               |  9 +++++++++
 src/roff/troff/node.cpp | 19 ++++++++++---------
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 924a43ca..7b3fe621 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-07-08  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/node.cpp (get_register, get_string): Reorder
+       null pointer inequality comparisons; they don't need to be in a
+       funny order because it's pretty hard to mistype `!=` as an
+       assignment operator.  Annotate them as null pointers to ease any
+       future migration to ISO C++11.  Use primitive type constructor
+       instead of C-style cast operator; this seems more idiomatic.
+
 2022-07-08  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/preproc/html/pre-html.cpp (generateImages): Flush the
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 0ddcd684..071c95a0 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -4030,23 +4030,25 @@ int tag_node::ends_sentence()
   return 2;
 }
 
-// Get contents of register `p`--used only by suppress_node::tprint().
+// Get contents of register `p` as integer.
+// Used only by suppress_node::tprint().
 static int get_register(const char *p)
 {
-  assert(0 != p);
+  assert(p != 0 /* nullptr */);
   reg *r = (reg *)number_reg_dictionary.lookup(p);
-  assert(0 != r);
+  assert(r != 0 /* nullptr */);
   units value;
   assert(r->get_value(&value));
-  return (int)value;
+  return int(value);
 }
 
-// Get contents of string `p`--used only by suppress_node::tprint().
+// Get contents of register `p` as string.
+// Used only by suppress_node::tprint().
 static const char *get_string(const char *p)
 {
-  assert(0 != p);
+  assert(p != 0 /* nullptr */);
   reg *r = (reg *)number_reg_dictionary.lookup(p);
-  assert(0 != r);
+  assert(r != 0 /* nullptr */);
   return r->get_string();
 }
 
@@ -4186,8 +4188,7 @@ void suppress_node::tprint(troff_output_file *out)
        //                    " suppress_start_page = %d\n",
        //        topdiv->get_page_number(), suppress_start_page);
 
-       // remember that the filename will contain a %d in which the
-       // image_no is placed
+       // `name` will contain a "%d" in which the image_no is placed.
        fprintf(stderr,
                "grohtml-info:page %d  %d  %d  %d  %d  %d  %s  %d  %d"
                "  %s\n",



reply via email to

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