gbranden pushed a commit to branch master
in repository groff.

commit 467605ced9a0b9c76ae734cd77ae25913babdacb
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Apr 8 09:27:12 2026 -0500

    [troff]: Refactor.
    
    Separate engine logic from input parsing logic with respect to
    configuration of an environment's inter-word and supplemental
    inter-sentence space sizes.
    
    * src/roff/troff/env.h: Stop globally declaring `space_size()`.
      (class environment): Declare new member functions returning `void`:
      `set_interword_space_size()`,
      `reset_supplemental_intersentence_space_size()`, and
      `set_supplemental_intersentence_space_size()`.  (The last two differ
      because callers of the former require no knowledge of the default
      supplemental inter-sentence space size.)  Drop declaration of `friend`
      function `space_size()`.
    
    * src/roff/troff/env.cpp (environment::set_interword_space_size)
      (environment::reset_supplemental_intersentence_space_size)
      (environment::set_supplemental_intersentence_space_size): New
      functions mutate object of `environment` class.
    
      (space_size): Replace manipulation of `environment` object's private
      member variables with calls of public member functions.
---
 ChangeLog              | 21 +++++++++++++++++++++
 src/roff/troff/env.cpp | 21 ++++++++++++++++++---
 src/roff/troff/env.h   |  5 +++--
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 31cd98bda..aadeb2f48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2026-04-08  G. Branden Robinson <[email protected]>
+
+       [troff]: Refactor.  Separate engine logic from input parsing
+       logic with respect to configuration of an environment's
+       inter-word and supplemental inter-sentence space sizes.
+
+       * src/roff/troff/env.h: Stop globally declaring `space_size()`.
+       (class environment): Declare new member functions returning
+       `void`: `set_interword_space_size()`,
+       `reset_supplemental_intersentence_space_size()`, and
+       `set_supplemental_intersentence_space_size()`.  (The last two
+       differ because callers of the former require no knowledge of the
+       default supplemental inter-sentence space size.)  Drop
+       declaration of `friend` function `space_size()`.
+       * src/roff/troff/env.cpp (environment::set_interword_space_size)
+       (environment::reset_supplemental_intersentence_space_size)
+       (environment::set_supplemental_intersentence_space_size): New
+       functions mutate object of `environment` class.
+       (space_size): Replace manipulation of `environment` object's
+       private member variables with calls of public member functions.
+
 2026-04-08  G. Branden Robinson <[email protected]>
 
        [groff]: Unit-test `ss` request.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index f0b7e497c..c7393d2a2 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1067,6 +1067,21 @@ bool 
environment::set_no_break_control_character(unsigned char c)
   return true;
 }
 
+void environment::set_interword_space_size(int n)
+{
+  space_size = n;
+}
+
+void environment::reset_supplemental_intersentence_space_size()
+{
+  sentence_space_size = space_size;
+}
+
+void environment::set_supplemental_intersentence_space_size(int n)
+{
+  sentence_space_size = n;
+}
+
 hunits environment::get_input_line_position()
 {
   hunits n;
@@ -1442,15 +1457,15 @@ void space_size()
     if (n < 0)
       warning(WARN_RANGE, "ignoring negative word space size: '%1'", n);
     else
-      curenv->space_size = n;
+      curenv->set_interword_space_size(n);
     if (has_arg() && read_integer(&n))
       if (n < 0)
        warning(WARN_RANGE, "ignoring negative sentence space size: "
                "'%1'", n);
       else
-       curenv->sentence_space_size = n;
+       curenv->set_supplemental_intersentence_space_size(n);
     else
-      curenv->sentence_space_size = curenv->space_size;
+      curenv->reset_supplemental_intersentence_space_size();
   }
   skip_line();
 }
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index c2e7935f6..dcaad14a8 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -110,7 +110,6 @@ class pending_output_line;
 // arguments and then, if everything is kosher, call curenv->[one of the
 // below]?  --GBR, 2026
 void title_length();
-void space_size();
 void fill();
 void no_fill();
 void adjust();
@@ -321,6 +320,9 @@ public:
   hunits get_space_width() { return env_space_width(this); }
   int get_space_size() { return space_size; }  // in ems/36
   int get_sentence_space_size() { return sentence_space_size; }
+  void set_interword_space_size(int);
+  void reset_supplemental_intersentence_space_size();
+  void set_supplemental_intersentence_space_size(int);
   hunits get_narrow_space_width() { return env_narrow_space_width(this); }
   hunits get_half_narrow_space_width()
     { return env_half_narrow_space_width(this); }
@@ -393,7 +395,6 @@ public:
   void dump_pending_nodes();
 
   friend void title_length();
-  friend void space_size();
   friend void fill();
   friend void no_fill();
   friend void adjust();

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

Reply via email to