groff-commit
[Top][All Lists]
Advanced

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

[groff] 12/48: [troff]: Boolify env.cpp (3/25).


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

gbranden pushed a commit to branch master
in repository groff.

commit a2f5832d7b1bdca08f87983683f2b221e531511d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Apr 26 21:45:16 2024 -0500

    [troff]: Boolify env.cpp (3/25).
    
    [troff]: Boolify more `environment` class member variables, member
    function parameters, and local variables.
    
    * src/roff/troff/env.cpp (class pending_output_line)
      (pending_output_line::pending_output_line)
      (pending_output_line::output, environment::mark_last_line)
      [WIDOW_CONTROL]: Rename `last_line` to `is_last_line` and demote it
      from `int` to `bool`.
    
    This isn't live code--in fact, James Clark "#ifdef"ed it out ~30 years
    ago--but I'm migrating it for consistency.  And someone may want to take
    up the gauntlet that James left on the ground back then: automatic widow
    prevention remains a problem unsolved by GNU troff.  (Or someone can
    carefully explain why the approach attempted here will never work.)
---
 ChangeLog              |  6 ++++++
 src/roff/troff/env.cpp | 10 +++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c981f2918..ba4903936 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,12 @@
        (class pending_output_line) [WIDOW_CONTROL]: Update prototype of
        `environment::output` friend declaration.
 
+       * src/roff/troff/env.cpp (class pending_output_line)
+       (pending_output_line::pending_output_line)
+       (pending_output_line::output, environment::mark_last_line)
+       [WIDOW_CONTROL]: Rename `last_line` to `is_last_line` and demote
+       it from `int` to `bool`.
+
 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 9b66030e9..8f3fb5dd7 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -85,7 +85,7 @@ class pending_output_line {
   vunits post_vs;
   hunits width;
 #ifdef WIDOW_CONTROL
-  int last_line;               // Is it the last line of the paragraph?
+  bool is_last_line;           // Is it the last line of the paragraph?
 #endif /* WIDOW_CONTROL */
 public:
   pending_output_line *next;
@@ -108,7 +108,7 @@ pending_output_line::pending_output_line(node *n, bool nf, 
vunits v,
 : nd(n), suppress_filling(nf), was_centered(ce), vs(v), post_vs(pv),
   width(w),
 #ifdef WIDOW_CONTROL
-  last_line(0),
+  is_last_line(false),
 #endif /* WIDOW_CONTROL */
   next(p)
 {
@@ -124,10 +124,10 @@ int pending_output_line::output()
   if (was_trap_sprung)
     return 0;
 #ifdef WIDOW_CONTROL
-  if (next && next->last_line && !suppress_filling) {
+  if (next && next->is_last_line && !suppress_filling) {
     curdiv->need(vs + post_vs + vunits(vresolution));
     if (was_trap_sprung) {
-      next->last_line = 0;     // Try to avoid infinite loops.
+      next->is_last_line = false;      // Try to avoid infinite loops.
       return 0;
     }
   }
@@ -205,7 +205,7 @@ void environment::mark_last_line()
   for (p = pending_lines; p->next; p = p->next)
     ;
   if (!p->suppress_filling)
-    p->last_line = 1;
+    p->is_last_line = true;
 }
 
 void widow_control_request()



reply via email to

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