groff-commit
[Top][All Lists]
Advanced

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

[groff] 17/48: [troff]: Boolify env.cpp (8/25).


From: G. Branden Robinson
Subject: [groff] 17/48: [troff]: Boolify env.cpp (8/25).
Date: Sun, 28 Apr 2024 23:06:21 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 8aa64ad4ce69ffe7853eec8de63fad6df9246109
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Apr 26 23:36:07 2024 -0500

    [troff]: Boolify env.cpp (8/25).
    
    [troff]: Boolify more `environment` class member variables, member
    function parameters, and local variables.
    
    * src/roff/troff/env.h (class environment):
    * src/roff/troff/env.cpp (environment::hyphenate_line)
      (environment::possibly_break_line):
      - Rename parameter `start_here` to `must_break_here` and demote
        it from `int` to `bool`.
    
    * src/roff/troff/env.cpp (environment::possibly_break_line):
      (environment::space_newline, environment::space)
      (environment::do_break):
    * src/roff/troff/input.cpp (process_input_stack):
      - Pass Boolean, not integer, literals to it.
    
    Comment out parameter names in prototypes, in a compromise with the
    Stroustrup-style C++ used in most of groff.
---
 ChangeLog                | 10 ++++++++++
 src/roff/troff/env.cpp   | 14 +++++++-------
 src/roff/troff/env.h     |  5 +++--
 src/roff/troff/input.cpp |  2 +-
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aa6a8b722..9cfe11e60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -60,6 +60,16 @@
          it from `int` to `bool`.
        - Assign Boolean literals to it.
 
+       * src/roff/troff/env.h (class environment):
+       * src/roff/troff/env.cpp (environment::hyphenate_line)
+       (environment::possibly_break_line):
+       - Rename parameter `start_here` to `must_break_here` and demote
+         it from `int` to `bool`.
+
+       * src/roff/troff/env.cpp (environment::possibly_break_line):
+       * src/roff/troff/input.cpp (process_input_stack):
+       - Pass Boolean, not integer, literals to it.
+
 2024-04-24  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/env.cpp (tab_stops::to_string)
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 5e9cbb301..7bb7d3fa7 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -482,7 +482,7 @@ void environment::space_newline()
     return;
   }
   add_node(new word_space_node(x, get_fill_color(), w));
-  possibly_break_line(0, spreading);
+  possibly_break_line(false, spreading);
   spreading = false;
 }
 
@@ -518,7 +518,7 @@ void environment::space(hunits space_width, hunits 
sentence_space_width)
                               get_fill_color(),
                               new width_list(space_width,
                                              sentence_space_width)));
-  possibly_break_line(0, spreading);
+  possibly_break_line(false, spreading);
   spreading = false;
 }
 
@@ -2086,12 +2086,12 @@ breakpoint *environment::choose_breakpoint()
   return 0;
 }
 
-void environment::hyphenate_line(int start_here)
+void environment::hyphenate_line(bool must_break_here)
 {
   assert(line != 0);
   hyphenation_type prev_type = line->get_hyphenation_type();
   node **startp;
-  if (start_here)
+  if (must_break_here)
     startp = &line;
   else
     for (startp = &line->next; *startp != 0; startp = &(*startp)->next) {
@@ -2198,7 +2198,7 @@ static void distribute_space(node *n, int nspaces, hunits 
desired_space,
     do_reverse_node_list = !do_reverse_node_list;
 }
 
-void environment::possibly_break_line(int start_here, int forced)
+void environment::possibly_break_line(bool must_break_here, int forced)
 {
   bool was_centered = center_lines > 0;
   if (!fill || current_tab || current_field || dummy)
@@ -2208,7 +2208,7 @@ void environment::possibly_break_line(int start_here, int 
forced)
             // When a macro follows a paragraph in fill mode, the
             // current line should not be empty.
             || (width_total - line->width()) > target_text_length)) {
-    hyphenate_line(start_here);
+    hyphenate_line(must_break_here);
     breakpoint *bp = choose_breakpoint();
     if (bp == 0)
       // we'll find one eventually
@@ -2475,7 +2475,7 @@ void environment::do_break(bool want_adjustment)
       line = new space_node(H0, get_fill_color(), line);
       space_total++;
     }
-    possibly_break_line(0, want_adjustment);
+    possibly_break_line(false, want_adjustment);
   }
   while (line != 0 && line->discardable()) {
     width_total -= line->width();
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 41394c8bd..a8d5f2ebb 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -243,7 +243,7 @@ class environment {
   void mark_last_line();
 #endif /* WIDOW_CONTROL */
   breakpoint *choose_breakpoint();
-  void hyphenate_line(int start_here = 0);
+  void hyphenate_line(bool /* must_break_here */ = false);
   void start_field();
   void wrap_up_field();
   void add_padding();
@@ -343,7 +343,8 @@ public:
   void set_input_line_position(hunits);        // used by \n(hp
   void interrupt();
   void spread() { spreading = true; }
-  void possibly_break_line(int start_here = 0, int forced = 0);
+  void possibly_break_line(bool /* must_break_here */ = false,
+                          int forced = 0);
   void do_break(bool /* want_adjustment */ = false);   // .br, .brp
   void final_break();
   node *make_tag(const char *name, int i);
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 8b0f02935..71aa97a37 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3111,7 +3111,7 @@ void process_input_stack()
          curenv->add_node(tok.nd);
          tok.nd = 0;
          bol = 0;
-         curenv->possibly_break_line(1);
+         curenv->possibly_break_line(true /* must break here */);
        }
        break;
       }



reply via email to

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