gbranden pushed a commit to branch master
in repository groff.

commit 506b9c7e74d4264c682f0fb7adf5be850ce0adf4
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu May 15 15:41:11 2025 -0500

    [troff]: Slightly refactor (boolify) (1/2).
    
    * src/roff/troff/node.cpp (class real_output_file): Demote member
      variable `printing` from `int` to `bool`, and rename it to
      `want_page_printed`.
    
      (real_output_file::real_output_file): Track rename and boolification
      in initializer and use of constant literal of Boolean type.
    
      (real_output_file::is_selected_for_printing)
      (real_output_file::begin_page)
      (real_output_file::copy_file)
      (real_output_file::transparent_char)
      (real_output_file::print_line): Track rename.
---
 ChangeLog               | 14 ++++++++++++++
 src/roff/troff/node.cpp | 16 ++++++++--------
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9111bb513..180e50e21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2025-05-15  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/node.cpp (class real_output_file): Demote
+       member variable `printing` from `int` to `bool`, and rename it
+       to `want_page_printed`.
+       (real_output_file::real_output_file): Track rename and
+       boolification in initializer and use of constant literal of
+       Boolean type.
+       (real_output_file::is_selected_for_printing)
+       (real_output_file::begin_page)
+       (real_output_file::copy_file)
+       (real_output_file::transparent_char)
+       (real_output_file::print_line): Track rename.
+
 2025-05-15  G. Branden Robinson <[email protected]>
 
        [troff]: Boolify member function of `output_file` class that
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index f5051949a..eff60f1a6 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -744,7 +744,7 @@ tfont::tfont(tfont_spec &spec) : tfont_spec(spec)
 
 class real_output_file : public output_file {
   int piped;
-  int printing;                // decision via optional page list
+  bool want_page_printed;      // if selected with `troff -o`
   bool is_output_on;   // controlled by \O[0], \O[1] escape sequences
   virtual void really_transparent_char(unsigned char) = 0;
   virtual void really_print_line(hunits x, vunits y, node *n,
@@ -1718,7 +1718,7 @@ void output_file::off()
 }
 
 real_output_file::real_output_file()
-: printing(0), is_output_on(true)
+: want_page_printed(true), is_output_on(true)
 {
   if (pipe_command) {
     if ((fp = popen(pipe_command, POPEN_WT)) != 0 /* nullptr */) {
@@ -1780,13 +1780,13 @@ void real_output_file::flush()
 
 bool real_output_file::is_selected_for_printing()
 {
-  return printing;
+  return want_page_printed;
 }
 
 void real_output_file::begin_page(int pageno, vunits page_length)
 {
-  printing = in_output_page_list(pageno);
-  if (printing) {
+  want_page_printed = in_output_page_list(pageno);
+  if (want_page_printed) {
     was_any_page_in_output_list = true;
     really_begin_page(pageno, page_length);
   }
@@ -1795,21 +1795,21 @@ void real_output_file::begin_page(int pageno, vunits 
page_length)
 void real_output_file::copy_file(hunits x, vunits y,
                                 const char *filename)
 {
-  if (printing && is_output_on)
+  if (want_page_printed && is_output_on)
     really_copy_file(x, y, filename);
   check_output_limits(x.to_units(), y.to_units());
 }
 
 void real_output_file::transparent_char(unsigned char c)
 {
-  if (printing && is_output_on)
+  if (want_page_printed && is_output_on)
     really_transparent_char(c);
 }
 
 void real_output_file::print_line(hunits x, vunits y, node *n,
                             vunits before, vunits after, hunits width)
 {
-  if (printing)
+  if (want_page_printed)
     really_print_line(x, y, n, before, after, width);
   delete_node_list(n);
 }

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

Reply via email to