gbranden pushed a commit to branch master
in repository groff.

commit bb70f8d1905a82b5b9b574e4716598ec4408dfed
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Aug 18 08:21:51 2024 -0500

    [troff]: Trivially refactor.
    
    * src/roff/troff/input.cpp (read_drawing_command): Boolify local
      variable `no_last_v`.  Rename local variable `err` to `had_error`.
    
    Also use spaces around binary operators.
    
    Also annotate null pointers with `nullptr` comment to ease any future
    transition to C++11, which defines it as a keyword.
---
 ChangeLog                |  6 ++++++
 src/roff/troff/input.cpp | 22 +++++++++++-----------
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4027a5d57..2429fd19e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-08-18  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (read_drawing_command): Trivially
+       refactor.  Boolify local variable `no_last_v`.  Rename local
+       variable `err` to `had_error`.
+
 2024-08-18  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (read_drawing_command): Demote
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 0274887a3..6a4e2561c 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7677,7 +7677,7 @@ bool token::add_to_zero_width_node_list(node **pp)
   case TOKEN_NODE:
   case TOKEN_HORIZONTAL_SPACE:
     n = nd;
-    nd = 0;
+    nd = 0 /* nullptr */;
     break;
   case TOKEN_NUMBERED_CHAR:
     *pp = (*pp)->add_char(get_charinfo_by_number(val), curenv, &w, &s);
@@ -8927,19 +8927,19 @@ static node *read_drawing_command()
       unsigned char type = tok.ch();
       if (type == 'F') {
        read_drawing_command_color_arguments(start_token);
-       return 0;
+       return 0 /* nullptr */;
       }
       tok.next();
       int maxpoints = 10;
       hvpair *point = new hvpair[maxpoints];
       int npoints = 0;
-      int no_last_v = 0;
-      bool err = false;
+      bool no_last_v = false;
+      bool had_error = false;
       int i;
       for (i = 0; tok != start_token; i++) {
        if (i == maxpoints) {
          hvpair *oldpoint = point;
-         point = new hvpair[maxpoints*2];
+         point = new hvpair[maxpoints * 2];
          for (int j = 0; j < maxpoints; j++)
            point[j] = oldpoint[j];
          maxpoints *= 2;
@@ -8948,30 +8948,30 @@ static node *read_drawing_command()
        if (tok.is_newline() || tok.is_eof()) {
          warning(WARN_DELIM, "missing closing delimiter in drawing"
                  " escape sequence (got %1)", tok.description());
-         err = true;
+         had_error = true;
          break;
        }
        if (!get_hunits(&point[i].h,
                        type == 'f' || type == 't' ? 'u' : 'm')) {
-         err = true;
+         had_error = true;
          break;
        }
        ++npoints;
        tok.skip();
        point[i].v = V0;
        if (tok == start_token) {
-         no_last_v = 1;
+         no_last_v = true;
          break;
        }
        if (!get_vunits(&point[i].v, 'v')) {
-         err = false;
+         had_error = false;
          break;
        }
        tok.skip();
       }
       while (tok != start_token && !tok.is_newline() && !tok.is_eof())
        tok.next();
-      if (!err) {
+      if (!had_error) {
        switch (type) {
        case 'l':
          if (npoints != 1 || no_last_v) {
@@ -9024,7 +9024,7 @@ static node *read_drawing_command()
       }
     }
   }
-  return 0;
+  return 0 /* nullptr */;
 }
 
 static void read_drawing_command_color_arguments(token &start)

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

Reply via email to