gbranden pushed a commit to branch master
in repository groff.

commit 8b165f90ef9eb62a5ddf33c79c956ce08aed4341
Author: G. Branden Robinson <[email protected]>
AuthorDate: 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.
---
 ChangeLog              | 12 ++++++++++++
 src/roff/troff/env.cpp | 11 +++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 989933ede..429b2c5dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2025-12-29  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/env.cpp: Refactor.  More cleanly separate input
+       processing logic from engine logic.
+       (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.
+
 2025-12-25  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp: Add new Boolean-valued parameter to
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 5b158f80d..6a633ba06 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2640,23 +2640,22 @@ bool environment::is_empty()
          && pending_lines == 0 /* nullptr */;
 }
 
-void do_break_request(bool want_adjustment)
+static void break_output_line(bool want_adjustment)
 {
-  while (!tok.is_newline() && !tok.is_eof())
-    tok.next();
   if (want_break)
     curenv->do_break(want_adjustment);
-  tok.next();
 }
 
 static void break_without_adjustment()
 {
-  do_break_request(false);
+  break_output_line(false);
+  skip_line();
 }
 
 static void break_with_adjustment()
 {
-  do_break_request(true);
+  break_output_line(true);
+  skip_line();
 }
 
 void title()

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

Reply via email to