gbranden pushed a commit to branch master
in repository groff.

commit 417f3b160151a14d2804708bbb79f9727b39bb78
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Aug 26 12:59:06 2024 -0500

    [troff]: Trivially refactor (`do_underline`).
    
    * src/roff/troff/env.h:
    * src/roff/troff/env.cpp (do_underline): Rename this...
      (configure_underlining): ...to this.
    
    * src/roff/troff/env.cpp (do_underline_special): Rename this...
      (configure_space_underlining): ...to this.  Now the argument is
      self-explanatory.
    
    Also drop stray note-to-self comment.
---
 ChangeLog              | 10 ++++++++++
 src/roff/troff/env.cpp | 22 ++++++++++------------
 src/roff/troff/env.h   |  4 ++--
 3 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4466c9828..bf40e74e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-08-26  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/env.h:
+       * src/roff/troff/env.cpp (do_underline): Rename this...
+       (configure_underlining): ...to this.
+
+       * src/roff/troff/env.cpp (do_underline_special): Rename this...
+       (configure_space_underlining): ...to this.  Now the argument is
+       self-explanatory.
+
 2024-08-26  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (main): Migrate `.T` register backing
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 31df9db2c..2076ef51c 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -383,8 +383,6 @@ void environment::add_node(node *nd)
        delete nd;
        return;
       }
-      // XXX: Should this really be done for device "special" nodes--"x"
-      // commands?
       start_line();
     }
     width_total += nd->width();
@@ -526,11 +524,11 @@ void environment::space(hunits space_width, hunits 
sentence_space_width)
   is_spreading = false;
 }
 
-static node *do_underline_special(bool do_underline_spaces)
+static node *configure_space_underlining(bool b)
 {
   macro m;
   m.append_str("x u ");
-  m.append(do_underline_spaces ? '1' : '0');
+  m.append(b ? '1' : '0');
   return new special_node(m, 1);
 }
 
@@ -561,9 +559,9 @@ bool environment::set_font(symbol nm)
   }
   if (underline_spaces && fontno != prev_fontno) {
     if (fontno == get_underline_fontno())
-      add_node(do_underline_special(true));
+      add_node(configure_space_underlining(true));
     if (prev_fontno == get_underline_fontno())
-      add_node(do_underline_special(false));
+      add_node(configure_space_underlining(false));
   }
   return true;
 }
@@ -1569,7 +1567,7 @@ void temporary_indent()
   tok.next();
 }
 
-void do_underline(bool want_spaces_underlined)
+void configure_underlining(bool want_spaces_underlined)
 {
   int n;
   if (!has_arg() || !get_integer(&n))
@@ -1580,7 +1578,7 @@ void do_underline(bool want_spaces_underlined)
       curenv->fontno = curenv->pre_underline_fontno;
       if (want_spaces_underlined) {
        curenv->underline_spaces = false;
-       curenv->add_node(do_underline_special(false));
+       curenv->add_node(configure_space_underlining(false));
       }
     }
     curenv->underlined_line_count = 0;
@@ -1591,7 +1589,7 @@ void do_underline(bool want_spaces_underlined)
     curenv->fontno = get_underline_fontno();
     if (want_spaces_underlined) {
       curenv->underline_spaces = true;
-      curenv->add_node(do_underline_special(true));
+      curenv->add_node(configure_space_underlining(true));
     }
   }
   skip_line();
@@ -1599,12 +1597,12 @@ void do_underline(bool want_spaces_underlined)
 
 void continuous_underline()
 {
-  do_underline(true /* want spaces underlined */);
+  configure_underlining(true /* underline spaces */);
 }
 
 void underline()
 {
-  do_underline(false /* want spaces underlined */);
+  configure_underlining(false /* underline spaces */);
 }
 
 void margin_character()
@@ -1793,7 +1791,7 @@ void environment::newline()
       fontno = pre_underline_fontno;
       if (underline_spaces) {
        underline_spaces = false;
-       add_node(do_underline_special(false));
+       add_node(configure_space_underlining(false));
       }
     }
   }
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 6e0600ae7..f64341d1c 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -115,7 +115,7 @@ void line_spacing();
 void line_length();
 void indent();
 void temporary_indent();
-void do_underline(bool);
+void configure_underlining(bool);
 void do_input_trap(bool);
 void set_tabs();
 void margin_character();
@@ -386,7 +386,7 @@ public:
   friend void line_length();
   friend void indent();
   friend void temporary_indent();
-  friend void do_underline(bool);
+  friend void configure_underlining(bool);
   friend void do_input_trap(bool);
   friend void set_tabs();
   friend void margin_character();

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

Reply via email to