[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 01/13: [troff]: Trivially refactor.
From: |
G. Branden Robinson |
Subject: |
[groff] 01/13: [troff]: Trivially refactor. |
Date: |
Mon, 25 Dec 2023 20:38:45 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit cf6e8e547e2c20c3692c1bcafb94eb4478ae4960
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Dec 18 15:39:03 2023 -0600
[troff]: Trivially refactor.
* src/roff/troff/env.cpp (environment::do_break)
(do_break_request): Boolify parameter and rename it to
`want_adjustment`. In the future, adjustment might not only "spread",
but "squeeze" as well.
(break_request): Rename this...
(break_without_adjustment): ...to this, and declare it `static`. Pass
Boolean literal to `do_break_request`.
(break_spread_request): Rename this...
(break_with_adjustment): ...to this, and declare it `static`. Pass
Boolean literal to `do_break_request`.
(init_env_requests): Update "call" sites of renamed functions.
* src/roff/troff/env.cpp (class environment): Demote `do_break`'s
parameter from `int` to `bool`, and drop parameter names from
prototype, in keeping with the Stroustrup-style C++ used in most of
groff.
However, when using default argument values, I'm retaining the parameter
name in a comment, mainly out of documentary instinct.
---
ChangeLog | 20 ++++++++++++++++++++
src/roff/troff/env.cpp | 20 ++++++++++----------
src/roff/troff/env.h | 2 +-
3 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7a44d8261..5d2759bfe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2023-12-18 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Trivially refactor.
+
+ * src/roff/troff/env.cpp (environment::do_break)
+ (do_break_request): Boolify parameter and rename it to
+ `want_adjustment`. In the future, adjustment might not only
+ "spread", but "squeeze" as well.
+ (break_request): Rename this...
+ (break_without_adjustment): ...to this, and declare it `static`.
+ Pass Boolean literal to `do_break_request`.
+ (break_spread_request): Rename this...
+ (break_with_adjustment): ...to this, and declare it `static`.
+ Pass Boolean literal to `do_break_request`.
+ (init_env_requests): Update "call" sites of renamed functions.
+ * src/roff/troff/env.cpp (class environment): Demote
+ `do_break`'s parameter from `int` to `bool`, and drop parameter
+ names from prototype, in keeping with the Stroustrup-style C++
+ used in most of groff.
+
2023-12-08 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp (nop_request, do_if_request)
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 942332d5d..e229135c8 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2410,7 +2410,7 @@ void environment::construct_new_line_state(node *n)
extern int global_diverted_space;
-void environment::do_break(int do_spread)
+void environment::do_break(bool want_adjustment)
{
int was_centered = 0;
if (curdiv == topdiv && topdiv->before_first_page) {
@@ -2425,7 +2425,7 @@ void environment::do_break(int do_spread)
line = new space_node(H0, get_fill_color(), line);
space_total++;
}
- possibly_break_line(0, do_spread);
+ possibly_break_line(0, want_adjustment);
}
while (line != 0 && line->discardable()) {
width_total -= line->width();
@@ -2469,23 +2469,23 @@ int environment::is_empty()
return !current_tab && line == 0 && pending_lines == 0;
}
-void do_break_request(int spread)
+void do_break_request(bool want_adjustment)
{
while (!tok.is_newline() && !tok.is_eof())
tok.next();
if (want_break)
- curenv->do_break(spread);
+ curenv->do_break(want_adjustment);
tok.next();
}
-void break_request()
+static void break_without_adjustment()
{
- do_break_request(0);
+ do_break_request(false);
}
-void break_spread_request()
+static void break_with_adjustment()
{
- do_break_request(1);
+ do_break_request(true);
}
void title()
@@ -3456,8 +3456,8 @@ void print_env()
void init_env_requests()
{
init_request("ad", adjust);
- init_request("br", break_request);
- init_request("brp", break_spread_request);
+ init_request("br", break_without_adjustment);
+ init_request("brp", break_with_adjustment);
init_request("ce", center);
init_request("cu", continuous_underline);
init_request("ev", environment_switch);
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 122f8d9ac..9dabf90ed 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -337,7 +337,7 @@ public:
void interrupt();
void spread() { spread_flag = 1; }
void possibly_break_line(int start_here = 0, int forced = 0);
- void do_break(int spread = 0); // .br
+ void do_break(bool /* want_adjustment */ = false); // .br, .brp
void final_break();
node *make_tag(const char *name, int i);
void newline();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 01/13: [troff]: Trivially refactor.,
G. Branden Robinson <=