URL:
  <https://savannah.gnu.org/bugs/?68240>

                 Summary: [long-term] [troff] improve separation of engine
logic from parser logic
                   Group: GNU roff
               Submitter: gbranden
               Submitted: Tue 14 Apr 2026 05:05:29 AM UTC
                Category: Core
                Severity: 1 - Wish
              Item Group: Refactoring
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Unlocked
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Tue 14 Apr 2026 05:05:29 AM UTC By: G. Branden Robinson <gbranden>
Here are some recent commits that establish the theme.


commit 84a617ec759de2650463269c053826620d61040e
Author: G. Branden Robinson <[email protected]>
Date:   Fri Apr 10 09:34:22 2026 -0500

    src/roff/troff/env.cpp: Refactor.
    
    * src/roff/troff/env.cpp: Lift logic for parsing a hyphenation exception
      word request argument into its own function, so that other requests
      can use it.
    
      (read_hyphenation_exception_word): Implement it.
    
      (add_hyphenation_exception_words_request): Call new function from
      here.

commit c01c66755c8c2fb0b2298b0c26020d7d19e2eb0c
Author: G. Branden Robinson <[email protected]>
Date:   Wed Apr 8 17:05:21 2026 -0500

    [troff]: Refactor.
    
    Separate engine logic from parsing logic with respect to an
    environment's filling enablement.
    
    * src/roff/troff/env.h: Stop globally declaring `fill()` and
      `no_fill()`.
    
      (class environment): Declare new member function returning `void`:
      `configure_filling()`.  Drop declaration of `friend` functions
      `fill()` and `no_fill()`.
    
    * src/roff/troff/env.cpp (environment::configure_filling): New function
      mutates object of `environment` class.
    
      (fill, no_fill): Replace manipulation of `environment` object's
      private member variable with calls of the foregoing new public member
      function.

commit 599374d9ab56d45bc5dd9f2aaea579e64768711a
Author: G. Branden Robinson <[email protected]>
Date:   Wed Apr 8 09:55:43 2026 -0500

    [troff]: Refactor.
    
    Separate engine logic from input parsing logic with respect to an
    environment's "line tabs" enablement (a GNU troff feature altering how
    tab stop positions are computed).
    
    * src/roff/troff/env.h: Stop globally declaring `line_tabs_request()`.
    
      (class environment): Declare new member function returning `void`:
      `configure_line_tabs()`.  Drop declaration of `friend` function
      `line_tabs_request()`.
    
    * src/roff/troff/env.cpp (environment::configure_line_tabs): New
      function mutates object of `environment` class.
    
      (line_tabs_request): Replace manipulation of `environment` object's
      private member variable with call of the foregoing new public member
      function.

commit 467605ced9a0b9c76ae734cd77ae25913babdacb
Author: G. Branden Robinson <[email protected]>
Date:   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.

commit f58faccc76cd39b7f4e5dbb03ead099c54d52e58
Author: G. Branden Robinson <[email protected]>
Date:   Mon Dec 29 03:59:56 2025 -0600

    src/roff/troff/env.cpp: Refactor.
    
    * src/roff/troff/env.cpp: Refactor.  Further separate input processing
      logic from engine logic.
    
      (environment::do_break): Rename argument from `want_adjustment` to
      `want_forced_adjustment` for clarity.
    
      (break_output_line): Stop checking value of `want_break` global here,
      as that's determined by the input control character used to invoke the
      request, a front-end rather than an engine concern {albeit brearing an
      engine-oriented name}.  However, removing that conditional leaves this
      function as a one-liner with two call sites differing only by a
      Boolean literal argument, so drop the function altogether, instead
      open-coding it...
      (break_without_adjustment, break_without_adjustment): ...here.

commit 8b165f90ef9eb62a5ddf33c79c956ce08aed4341
Author: G. Branden Robinson <[email protected]>
Date:   Mon Dec 29 03:00:00 2025 -0600

    src/roff/troff/env.cpp: Refactor.
    
    More cleanly separate input processing logic from engine logic.
    
    * src/roff/troff/env.cpp (do_break_request): Rename this...
      (break_output_line): ...to this.  Mark it `static` since it does not
      require external linkage.  Drop its manipulation of the input stream
      via the global `tok` object...
    
      (break_without_adjustment, break_without_adjustment): ...in favor of
      simply calling `skip_line()` from these handlers for the `br` and
      `brp` requests, which take no arguments.

commit 1983fe71fbf5df81ec66358edea945b95b89b533
Author: G. Branden Robinson <[email protected]>
Date:   Sun Dec 21 12:31:35 2025 -0600

    [troff]: Refactor (2/2).
    
    Move page offset access from language parser logic into "engine" logic.
    
    * src/roff/troff/div.h: Drop unnecessary declaration of `page_offset()`
      returning `void`.  This concealed a latent symbol visibility problem.
    
      (class top_level_diversion): Declare new member function
      `get_previous_page_offset()`, giving it a simple inline definition
      akin to the existing `get_page_offset()`.
    
    * src/roff/troff/div.cpp (page_offset): Make request handler use
      accessor member functions instead of retrieving the diversion's
      properties directly.

commit 06ae6d9c0d6430b98307ff4ed8b68f09d6f2efde
Author: G. Branden Robinson <[email protected]>
Date:   Sun Dec 21 12:15:16 2025 -0600

    [troff]: Refactor (1/2).
    
    Move page offset updates from language parser logic into "engine" logic.
    
    * src/roff/troff/div.h (class top_level_diversion): Declare new member
      function `set_page_offset()`.
    
      (top_level_diversion::set_page_offset): Define it, and make it
      responsible for updating both `page_offset` and `prev_page_offset`
      private member variables.
    
    * src/roff/troff/div.cpp (page_offset): Make request handler call this
      new mutator member function instead of manipulating the diversion's
      properties directly.









    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68240>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to