gbranden pushed a commit to branch master
in repository groff.

commit 0ff1e95dbbb57e0fb60bd107c0e554950f48270b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Oct 20 12:30:38 2025 -0500

    [troff]: Trivially refactor.
    
    Rename `line_interrupted` member variable of class `environment` to
    `was_line_interrupted`; since it stores a Boolean value, its name should
    clearly imply a logical predicate.  Rename `environment`'s member
    variable `was_previous_line_interrupted` analogously--even though it is
    an `int` because it is a kludgy three-valued Boolean.  (The extra value
    encodes whether a formatter exit is underway, I think.) Rename member
    function `get_prev_line_interrupted()` to
    `get_was_previous_line_interrupted()` analogously.  Rename (and
    unabbreviate) `saved_prev_line_interrupted` member variable of class
    `diversion` to `saved_was_previous_line_interrupted` analogously.
    
    * src/roff/troff/div.h (class diversion):
    * src/roff/troff/env.h (class environment): Do it.
    
    * src/roff/troff/div.cpp (do_divert):
    * src/roff/troff/env.cpp (environment::add_char)
      (environment::add_node, environment::add_hyphen_indicator)
      (environment::space_newline, environment::space)
      (environment::set_font, environment::set_family)
      (environment::set_size, environment::set_char_height)
      (environment::set_char_slant, environment::set_stroke_color)
      (environment::set_fill_color, environment::environment)
      (environment::copy, environment::interrupt)
      (environment::newline, environment::final_break)
      (environment::do_break, environment::dump, init_env_requests):
    * src/roff/troff/input.cpp (process_input_stack): Update call and
      dereference sites.
---
 ChangeLog                | 31 +++++++++++++++++++++++++
 src/roff/troff/div.cpp   |  8 +++----
 src/roff/troff/div.h     |  2 +-
 src/roff/troff/env.cpp   | 60 ++++++++++++++++++++++++------------------------
 src/roff/troff/env.h     |  6 ++---
 src/roff/troff/input.cpp |  4 ++--
 6 files changed, 71 insertions(+), 40 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cc9dec956..64463100e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2025-10-20  G. Branden Robinson <[email protected]>
+
+       [troff]: Trivially refactor.  Rename `line_interrupted` member
+       variable of class `environment` to `was_line_interrupted`; since
+       it stores a Boolean value, its name should clearly imply a
+       logical predicate.  Rename `environment`'s member variable
+       `was_previous_line_interrupted` analogously--even though it is
+       an `int` because it is a kludgy three-valued Boolean.  (The
+       extra value encodes whether a formatter exit is underway, I
+       think.) Rename member function `get_prev_line_interrupted()` to
+       `get_was_previous_line_interrupted()` analogously.  Rename (and
+       unabbreviate) `saved_prev_line_interrupted` member variable of
+       class `diversion` to `saved_was_previous_line_interrupted`
+       analogously.
+
+       * src/roff/troff/div.h (class diversion):
+       * src/roff/troff/env.h (class environment): Do it.
+       * src/roff/troff/div.cpp (do_divert):
+       * src/roff/troff/env.cpp (environment::add_char)
+       (environment::add_node, environment::add_hyphen_indicator)
+       (environment::space_newline, environment::space)
+       (environment::set_font, environment::set_family)
+       (environment::set_size, environment::set_char_height)
+       (environment::set_char_slant, environment::set_stroke_color)
+       (environment::set_fill_color, environment::environment)
+       (environment::copy, environment::interrupt)
+       (environment::newline, environment::final_break)
+       (environment::do_break, environment::dump, init_env_requests):
+       * src/roff/troff/input.cpp (process_input_stack): Update call
+       and dereference sites.
+
 2025-10-20  G. Branden Robinson <[email protected]>
 
        [ms]: Support floating keeps on cover page.  (Traditionally, a
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index 54058f878..7c29e2428 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -120,8 +120,8 @@ void do_divert(bool appending, bool boxing)
        curenv->space_total = curdiv->saved_space_total;
        curenv->saved_indent = curdiv->saved_saved_indent;
        curenv->target_text_length = curdiv->saved_target_text_length;
-       curenv->prev_line_interrupted
-         = curdiv->saved_prev_line_interrupted;
+       curenv->was_previous_line_interrupted
+         = curdiv->saved_was_previous_line_interrupted;
       }
       diversion *temp = curdiv;
       curdiv = curdiv->prev;
@@ -147,8 +147,8 @@ void do_divert(bool appending, bool boxing)
       curdiv->saved_space_total = curenv->space_total;
       curdiv->saved_saved_indent = curenv->saved_indent;
       curdiv->saved_target_text_length = curenv->target_text_length;
-      curdiv->saved_prev_line_interrupted
-       = curenv->prev_line_interrupted;
+      curdiv->saved_was_previous_line_interrupted
+       = curenv->was_previous_line_interrupted;
       curenv->line = 0 /* nullptr */;
       curenv->start_line();
     }
diff --git a/src/roff/troff/div.h b/src/roff/troff/div.h
index 5db83b883..38c6eb27b 100644
--- a/src/roff/troff/div.h
+++ b/src/roff/troff/div.h
@@ -29,7 +29,7 @@ class diversion {
   int saved_space_total;
   hunits saved_saved_indent;
   hunits saved_target_text_length;
-  int saved_prev_line_interrupted; // three-valued Boolean :-|
+  int saved_was_previous_line_interrupted; // three-valued Boolean :-|
 protected:
   symbol nm;
   vunits vertical_position;
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 7055f27ee..b8c2ee37e 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -343,7 +343,7 @@ void leader_character_request()
 void environment::add_char(charinfo *ci)
 {
   node *gc_np = 0 /* nullptr */;
-  if (line_interrupted)
+  if (was_line_interrupted)
     ;
   // don't allow fields in dummy environments
   else if (ci == field_delimiter_char && !is_dummy_env) {
@@ -414,7 +414,7 @@ void environment::add_node(node *nd)
 
   if ((current_tab != TAB_NONE) || has_current_field)
     nd->freeze_space();
-  if (line_interrupted) {
+  if (was_line_interrupted) {
     delete nd;
   }
   else if (current_tab != TAB_NONE) {
@@ -441,7 +441,7 @@ void environment::add_node(node *nd)
 
 void environment::add_hyphen_indicator()
 {
-  if ((current_tab != TAB_NONE) || line_interrupted || has_current_field
+  if ((current_tab != TAB_NONE) || was_line_interrupted || has_current_field
       || hyphen_indicator_char != 0 /* nullptr */)
     return;
   if (line == 0 /* nullptr */)
@@ -512,7 +512,7 @@ void environment::add_italic_correction()
 void environment::space_newline()
 {
   assert((current_tab == TAB_NONE) && !has_current_field);
-  if (line_interrupted)
+  if (was_line_interrupted)
     return;
   hunits x = H0;
   hunits sw = env_space_width(this);
@@ -541,7 +541,7 @@ void environment::space()
 
 void environment::space(hunits space_width, hunits sentence_space_width)
 {
-  if (line_interrupted)
+  if (was_line_interrupted)
     return;
   if (has_current_field && padding_indicator_char == 0 /* nullptr */) {
     add_padding();
@@ -597,7 +597,7 @@ static void warn_if_font_name_deprecated(symbol nm)
 
 bool environment::set_font(symbol nm)
 {
-  if (line_interrupted) {
+  if (was_line_interrupted) {
     warning(WARN_FONT, "ignoring font selection on interrupted line");
     return true; // "no operation" is successful
   }
@@ -634,7 +634,7 @@ bool environment::set_font(symbol nm)
 
 bool environment::set_font(int n)
 {
-  if (line_interrupted)
+  if (was_line_interrupted)
     return false;
   if (is_valid_font_mounting_position(n)) {
     prev_fontno = fontno;
@@ -649,7 +649,7 @@ bool environment::set_font(int n)
 
 void environment::set_family(symbol fam)
 {
-  if (line_interrupted)
+  if (was_line_interrupted)
     return;
   if (fam.is_null() || fam.is_empty()) {
     int previous_mounting_position = prev_family->resolve(fontno);
@@ -680,7 +680,7 @@ void environment::set_family(symbol fam)
 
 void environment::set_size(int n)
 {
-  if (line_interrupted)
+  if (was_line_interrupted)
     return;
   if (n == 0) {
     font_size temp = prev_size;
@@ -700,7 +700,7 @@ void environment::set_size(int n)
 
 void environment::set_char_height(int n)
 {
-  if (line_interrupted)
+  if (was_line_interrupted)
     return;
   if (n == requested_size || n <= 0)
     char_height = 0;
@@ -710,7 +710,7 @@ void environment::set_char_height(int n)
 
 void environment::set_char_slant(int n)
 {
-  if (line_interrupted)
+  if (was_line_interrupted)
     return;
   char_slant = n;
 }
@@ -737,7 +737,7 @@ color *environment::get_fill_color()
 
 void environment::set_stroke_color(color *c)
 {
-  if (line_interrupted)
+  if (was_line_interrupted)
     return;
   curenv->prev_stroke_color = curenv->stroke_color;
   curenv->stroke_color = c;
@@ -745,7 +745,7 @@ void environment::set_stroke_color(color *c)
 
 void environment::set_fill_color(color *c)
 {
-  if (line_interrupted)
+  if (was_line_interrupted)
     return;
   curenv->prev_fill_color = curenv->fill_color;
   curenv->fill_color = c;
@@ -767,8 +767,8 @@ environment::environment(symbol nm)
   sentence_space_size(12),
   adjust_mode(ADJUST_BOTH),
   is_filling(true),
-  line_interrupted(false),
-  prev_line_interrupted(0),
+  was_line_interrupted(false),
+  was_previous_line_interrupted(0),
   centered_line_count(0),
   right_aligned_line_count(0),
   prev_vertical_spacing(points_to_units(12)),
@@ -861,8 +861,8 @@ environment::environment(const environment *e)
   sentence_space_size(e->sentence_space_size),
   adjust_mode(e->adjust_mode),
   is_filling(e->is_filling),
-  line_interrupted(false),
-  prev_line_interrupted(0),
+  was_line_interrupted(false),
+  was_previous_line_interrupted(0),
   centered_line_count(0),
   right_aligned_line_count(0),
   prev_vertical_spacing(e->prev_vertical_spacing),
@@ -943,8 +943,8 @@ void environment::copy(const environment *e)
   sentence_space_size = e->sentence_space_size;
   adjust_mode = e->adjust_mode;
   is_filling = e->is_filling;
-  line_interrupted = false;
-  prev_line_interrupted = 0;
+  was_line_interrupted = false;
+  was_previous_line_interrupted = 0;
   centered_line_count = 0;
   right_aligned_line_count = 0;
   prev_vertical_spacing = e->prev_vertical_spacing;
@@ -1841,7 +1841,7 @@ void environment::interrupt()
 {
   if (!is_dummy_env) {
     add_node(new transparent_dummy_node);
-    line_interrupted = true;
+    was_line_interrupted = true;
   }
 }
 
@@ -1872,13 +1872,13 @@ void environment::newline()
   }
   node *to_be_output = 0 /* nullptr */;
   hunits to_be_output_width;
-  prev_line_interrupted = 0;
+  was_previous_line_interrupted = 0;
   if (is_dummy_env)
     space_newline();
-  else if (line_interrupted) {
-    line_interrupted = false;
+  else if (was_line_interrupted) {
+    was_line_interrupted = false;
     // see environment::final_break
-    prev_line_interrupted = is_exit_underway ? 2 : 1;
+    was_previous_line_interrupted = is_exit_underway ? 2 : 1;
   }
   else if (centered_line_count > 0) {
     --centered_line_count;
@@ -1920,7 +1920,7 @@ void environment::newline()
     hyphen_line_count = 0;
   }
   if (input_trap_count > 0) {
-    if (!(continued_input_trap && prev_line_interrupted))
+    if (!(continued_input_trap && was_previous_line_interrupted))
       if (--input_trap_count == 0)
        spring_trap(input_trap);
   }
@@ -2436,7 +2436,7 @@ bottom of this page.
 
 void environment::final_break()
 {
-  if (prev_line_interrupted == 2) {
+  if (was_previous_line_interrupted == 2) {
     do_break();
     add_node(new transparent_dummy_node);
   }
@@ -2620,7 +2620,7 @@ void environment::do_break(bool want_adjustment)
     output_line(tem, width_total, was_centered);
     hyphen_line_count = 0;
   }
-  prev_line_interrupted = 0;
+  was_previous_line_interrupted = 0;
 #ifdef WIDOW_CONTROL
   mark_last_line();
   output_pending_lines();
@@ -3516,7 +3516,7 @@ void environment::dump()
   // or meaningless.
   //
   //   char_height, char_slant,
-  //   line_interrupted
+  //   was_line_interrupted
   //   current_tab, tab_width, tab_distance
   //   has_current_field, field_distance, pre_field_width, field_spaces,
   //     tab_field_spaces, tab_precedes_field
@@ -3549,7 +3549,7 @@ void environment::dump()
           prev_title_length.to_units());
   errprint("  title line length: %1u\n", title_length.to_units());
   errprint("  previous line interrupted/continued: %1\n",
-          prev_line_interrupted ? "yes" : "no");
+          was_previous_line_interrupted ? "yes" : "no");
   errprint("  filling: %1\n", is_filling ? "on" : "off");
   errprint("  alignment/adjustment: %1\n",
           adjust_mode == ADJUST_LEFT
@@ -4390,7 +4390,7 @@ void init_env_requests()
   init_hunits_env_reg(".hys", get_hyphenation_space);
   init_hunits_env_reg(".i", get_indent);
   init_hunits_env_reg(".in", get_saved_indent);
-  init_int_env_reg(".int", get_prev_line_interrupted);
+  init_int_env_reg(".int", get_was_previous_line_interrupted);
   init_int_env_reg(".it", get_input_trap_line_count);
   init_int_env_reg(".itc", get_input_trap_respects_continuation);
   init_string_env_reg(".itm", get_input_trap_macro);
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index a70e42224..418163b02 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -157,8 +157,8 @@ class environment {
   int sentence_space_size;     // same but for spaces at the end of sentences
   int adjust_mode;
   bool is_filling;
-  bool line_interrupted;
-  int prev_line_interrupted;   // three-valued Boolean :-|
+  bool was_line_interrupted;
+  int was_previous_line_interrupted;   // three-valued Boolean :-|
   int centered_line_count;
   int right_aligned_line_count;
   vunits prev_vertical_spacing;
@@ -329,7 +329,7 @@ public:
   const char *get_input_trap_macro();
   int get_right_aligned_line_count();
   int get_no_number_count();
-  int get_prev_line_interrupted() { return prev_line_interrupted; }
+  int get_was_previous_line_interrupted() { return 
was_previous_line_interrupted; }
   color *get_fill_color();
   color *get_stroke_color();
   color *get_prev_stroke_color();
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index f2bbd9238..f56b8987c 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3217,7 +3217,7 @@ void process_input_stack()
       {
        if (reading_beginning_of_input_line
            && !have_formattable_input_on_interrupted_line
-           && !curenv->get_prev_line_interrupted())
+           && !curenv->get_was_previous_line_interrupted())
          trapping_blank_line();
        else {
          curenv->newline();
@@ -3256,7 +3256,7 @@ void process_input_stack()
        if (possibly_handle_first_page_transition())
          ;
        else if (reading_beginning_of_input_line
-                && !curenv->get_prev_line_interrupted()) {
+                && !curenv->get_was_previous_line_interrupted()) {
          int nspaces = 0;
          // save space_width now so that it isn't changed by \f or \s
          // which we wouldn't notice here

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

Reply via email to