gbranden pushed a commit to branch master
in repository groff.
commit a362f963d5433932c5a6a1610754fbc712482236
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Dec 29 04:15:21 2025 -0600
[troff]: Slightly refactor.
* src/roff/troff/env.h: Rename `want_break` global Boolean, relocating
its declaration from here...
* src/roff/troff/input.h: ...to here, as
`was_invoked_with_regular_control_character`. Yes, it's a mouthful,
but it is the task of the request handlers, which are input processing
functions, to interpret *roff's two distinct control characters,
giving them one of them break suppression semantics.
* src/roff/troff/div.cpp (begin_page, space_request, flush_request):
* src/roff/troff/env.cpp (fill, no_fill, center, right_justify, indent)
(temporary_indent, break_without_forced_adjustment_request)
(break_with_forced_adjustment_request):
* src/roff/troff/input.cpp (process_input_stack)
(macro_iterator::macro_iterator)
(unsafe_transparent_throughput_file_request)
(transparent_throughput_file_request): Update dereference sites.
* src/roff/troff/input.cpp: Update definition.
* src/roff/troff/div.cpp: Include local "input.h" header file to get at
the symbol's relocated declaration.
---
ChangeLog | 26 ++++++++++++++++++++++++++
src/roff/troff/div.cpp | 9 +++++----
src/roff/troff/env.cpp | 16 ++++++++--------
src/roff/troff/env.h | 1 -
src/roff/troff/input.cpp | 14 ++++++++------
src/roff/troff/input.h | 1 +
6 files changed, 48 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ba892ac8e..5d4f2af26 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2025-12-29 G. Branden Robinson <[email protected]>
+
+ [troff]: Slightly refactor.
+
+ * src/roff/troff/env.h: Rename `want_break` global Boolean,
+ relocating its declaration from here...
+ * src/roff/troff/input.h: ...to here, as
+ `was_invoked_with_regular_control_character`. Yes, it's a
+ mouthful, but it is the task of the request handlers, which are
+ input processing functions, to interpret *roff's two distinct
+ control characters, giving them one of them break suppression
+ semantics.
+ * src/roff/troff/div.cpp (begin_page, space_request)
+ (flush_request):
+ * src/roff/troff/env.cpp (fill, no_fill, center, right_justify)
+ (indent, temporary_indent)
+ (break_without_forced_adjustment_request)
+ (break_with_forced_adjustment_request):
+ * src/roff/troff/input.cpp (process_input_stack)
+ (macro_iterator::macro_iterator)
+ (unsafe_transparent_throughput_file_request)
+ (transparent_throughput_file_request): Update dereference sites.
+ * src/roff/troff/input.cpp: Update definition.
+ * src/roff/troff/div.cpp: Include local "input.h" header file to
+ get at the symbol's relocated declaration.
+
2025-12-29 G. Branden Robinson <[email protected]>
* src/roff/troff/env.cpp: Refactor. Further separate input
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index a3ff49cf6..983f39cfe 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -37,6 +37,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include "token.h"
#include "div.h"
#include "reg.h"
+#include "input.h" // was_invoked_with_regular_control_character
#include "nonposix.h"
@@ -788,7 +789,7 @@ static void begin_page()
tok.next();
if (curdiv == topdiv) {
if (topdiv->before_first_page_status > 0) {
- if (!want_break) {
+ if (!was_invoked_with_regular_control_character) {
if (got_arg)
topdiv->set_next_page_number(n);
if (got_arg || !topdiv->is_in_no_space_mode)
@@ -821,7 +822,7 @@ static void begin_page()
}
else {
push_page_ejector();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
if (got_arg)
topdiv->set_next_page_number(n);
@@ -858,7 +859,7 @@ sprung, then we don't actually do the space. */
static void space_request()
{
postpone_traps();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
vunits n;
if (!has_arg() || !read_vunits(&n, 'v'))
@@ -945,7 +946,7 @@ static void flush_request()
{
while (!tok.is_newline() && !tok.is_eof())
tok.next();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
if (the_output != 0 /* nullptr */)
the_output->flush();
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 1c46db641..b49471f2a 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1439,7 +1439,7 @@ void fill()
{
while (!tok.is_newline() && !tok.is_eof())
tok.next();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
curenv->is_filling = true;
tok.next();
@@ -1449,7 +1449,7 @@ void no_fill()
{
while (!tok.is_newline() && !tok.is_eof())
tok.next();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
curenv->is_filling = false;
curenv->suppress_next_eol = true;
@@ -1465,7 +1465,7 @@ void center()
n = 0;
while (!tok.is_newline() && !tok.is_eof())
tok.next();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
curenv->right_aligned_line_count = 0;
curenv->centered_line_count = n;
@@ -1482,7 +1482,7 @@ void right_justify()
n = 0;
while (!tok.is_newline() && !tok.is_eof())
tok.next();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
curenv->centered_line_count = 0;
curenv->right_aligned_line_count = n;
@@ -1591,7 +1591,7 @@ void indent()
temp = curenv->prev_indent;
while (!tok.is_newline() && !tok.is_eof())
tok.next();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
curenv->have_temporary_indent = false;
curenv->prev_indent = curenv->indent;
@@ -1617,7 +1617,7 @@ void temporary_indent()
while (!tok.is_newline() && !tok.is_eof())
tok.next();
}
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
if (temp < H0) {
warning(WARN_RANGE, "treating total indentation %1u as zero",
@@ -2647,14 +2647,14 @@ bool environment::is_empty()
static void break_without_forced_adjustment_request()
{
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break(false /* want forced adjustment */);
skip_line();
}
static void break_with_forced_adjustment_request()
{
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break(true /* want forced adjustment */);
skip_line();
}
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index ab4bd8e0e..5484d2cae 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -435,7 +435,6 @@ void init_environments();
extern double spread_limit;
-extern bool want_break;
extern symbol default_family;
extern bool translate_space_to_dummy;
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index be4afcded..050f23dec 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -97,7 +97,7 @@ void vjustify();
static void transparent_throughput_file_request();
token tok;
-bool want_break = false;
+bool was_invoked_with_regular_control_character = false;
bool using_character_classes = false;
static bool permit_color_output = true;
bool want_color_output = true;
@@ -3501,7 +3501,8 @@ void process_input_stack()
if (reading_beginning_of_input_line && !have_formattable_input
&& (curenv->get_control_character() == ch
|| curenv->get_no_break_control_character() == ch)) {
- want_break = (curenv->get_control_character() == ch);
+ was_invoked_with_regular_control_character
+ = (curenv->get_control_character() == ch);
// skip tabs as well as spaces here
do {
tok.next();
@@ -4748,7 +4749,7 @@ macro_iterator::macro_iterator(symbol s, macro &m,
const char *how_called,
bool want_arguments_initialized)
: string_iterator(m, how_called, s), args(0 /* nullptr */), argc(0),
- with_break(want_break)
+ with_break(was_invoked_with_regular_control_character)
{
if (want_arguments_initialized) {
arg_list *al = input_stack::get_arg_list();
@@ -4760,7 +4761,8 @@ macro_iterator::macro_iterator(symbol s, macro &m,
}
macro_iterator::macro_iterator()
-: args(0 /* nullptr */), argc(0), with_break(want_break)
+: args(0 /* nullptr */), argc(0),
+ with_break(was_invoked_with_regular_control_character)
{
}
@@ -9435,7 +9437,7 @@ static void unsafe_transparent_throughput_file_request()
return;
}
char *filename = read_rest_of_line_as_argument();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
if (filename != 0 /* nullptr */)
curdiv->copy_file(filename);
@@ -9478,7 +9480,7 @@ static void transparent_throughput_file_request()
return;
}
char *filename = read_rest_of_line_as_argument();
- if (want_break)
+ if (was_invoked_with_regular_control_character)
curenv->do_break();
if (filename != 0 /* nullptr */) {
errno = 0;
diff --git a/src/roff/troff/input.h b/src/roff/troff/input.h
index 0910add07..37a10cd0c 100644
--- a/src/roff/troff/input.h
+++ b/src/roff/troff/input.h
@@ -68,6 +68,7 @@ const int INPUT_SOFT_HYPHEN = 0255; // \u00ad
extern void do_stroke_color(symbol);
extern void do_fill_color(symbol);
+extern bool was_invoked_with_regular_control_character;
extern bool suppress_push;
extern bool want_nodes_dumped;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit