gbranden pushed a commit to branch master
in repository groff.
commit f58faccc76cd39b7f4e5dbb03ead099c54d52e58
Author: G. Branden Robinson <[email protected]>
AuthorDate: 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.
---
ChangeLog | 15 +++++++++++++++
src/roff/troff/env.cpp | 24 +++++++++++-------------
2 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6da3aadc2..ba892ac8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-12-29 G. Branden Robinson <[email protected]>
+
+ * 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.
+
2025-12-29 G. Branden Robinson <[email protected]>
[groff]: Unit-test `br` and `brp` requests.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 6a226ab2f..1c46db641 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2578,7 +2578,11 @@ void environment::construct_new_line_state(node *nd)
extern int global_diverted_space;
-void environment::do_break(bool want_adjustment)
+// "Forced adjustment" refers to spreading of adjustable spaces (and
+// perhaps only that, even if in the future we implement "squeezing"),
+// when it is not normally called for, as at the end of a paragraph.
+
+void environment::do_break(bool want_forced_adjustment)
{
bool was_centered = false;
if ((curdiv == topdiv) && (topdiv->before_first_page_status > 0)) {
@@ -2593,7 +2597,8 @@ void environment::do_break(bool want_adjustment)
line = new space_node(H0, get_fill_color(), line);
space_total++;
}
- possibly_break_line(false /* must break here */, want_adjustment);
+ possibly_break_line(false /* must break here */,
+ want_forced_adjustment);
}
while (line != 0 /* nullptr */ && line->discardable()) {
width_total -= line->width();
@@ -2640,24 +2645,17 @@ bool environment::is_empty()
&& pending_lines == 0 /* nullptr */;
}
-// "Forced adjustment" refers to spreading of adjustable spaces (and
-// perhaps only that, even if in the future we implement "squeezing"),
-// when it is not normally called for, as at the end of a paragraph.
-static void break_output_line(bool want_forced_adjustment)
-{
- if (want_break)
- curenv->do_break(want_forced_adjustment);
-}
-
static void break_without_forced_adjustment_request()
{
- break_output_line(false /* want forced adjustment */);
+ if (want_break)
+ curenv->do_break(false /* want forced adjustment */);
skip_line();
}
static void break_with_forced_adjustment_request()
{
- break_output_line(true /* want forced adjustment */);
+ if (want_break)
+ curenv->do_break(true /* want forced adjustment */);
skip_line();
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit