groff-commit
[Top][All Lists]
Advanced

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

[groff] 06/13: [troff]: Boolify `set_tabs` function.


From: G. Branden Robinson
Subject: [groff] 06/13: [troff]: Boolify `set_tabs` function.
Date: Sat, 11 Sep 2021 16:20:11 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 2ba79729985ffe621fae00fbfc144c0a9e782980
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Sep 11 06:28:25 2021 +1000

    [troff]: Boolify `set_tabs` function.
    
    * src/roff/troff/env.cpp (set_tabs): Demote local variables from `int`
      to `bool` and give them predicate-like names.
        - `first` -> `is_first_stop`
        - `repeated` -> `is_repeating_stop`
      Use Boolean instead of integer literals in assignments to them.
---
 ChangeLog              | 10 ++++++++++
 src/roff/troff/env.cpp | 12 ++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 495b99e..e147ac0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2021-09-11  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       [troff]: Boolify `set_tabs` function.
+
+       * src/roff/troff/env.cpp (set_tabs): Demote local variables from
+       `int` to `bool` and give them predicate-like names.
+         - `first` -> `is_first_stop`
+         - `repeated` -> `is_repeating_stop`
+       Use Boolean instead of integer literals in assignments to them.
+
+2021-09-11  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        [man]: Deprecate `OP` macro.
 
        * tmac/an-ext.tmac (OP): Move implementation from here...
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 7370de7..22754b3 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2756,13 +2756,13 @@ void set_tabs()
 {
   hunits pos;
   hunits prev_pos = 0;
-  int first = 1;
-  int repeated = 0;
+  bool is_first_stop = true;
+  bool is_repeating_stop = false;
   tab_stops tabs;
   while (has_arg()) {
     if (tok.ch() == TAB_REPEAT_CHAR) {
       tok.next();
-      repeated = 1;
+      is_repeating_stop = true;
       prev_pos = 0;
     }
     if (!get_hunits(&pos, 'm', prev_pos))
@@ -2779,13 +2779,13 @@ void set_tabs()
     else if (tok.ch() == 'L') {
       tok.next();
     }
-    if (pos <= prev_pos && !first)
+    if (pos <= prev_pos && !is_first_stop)
       warning(WARN_RANGE,
              "positions of tab stops must be strictly increasing");
     else {
-      tabs.add_tab(pos, type, repeated);
+      tabs.add_tab(pos, type, is_repeating_stop);
       prev_pos = pos;
-      first = 0;
+      is_first_stop = false;
     }
   }
   curenv->tabs = tabs;



reply via email to

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