gbranden pushed a commit to branch master
in repository groff.
commit 0d15414cdb4e7fc994cf27fe072a13b7b5e37a49
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Apr 26 21:39:01 2024 -0500
[troff]: Boolify env.cpp (2/25).
[troff]: Boolify more `environment` class member variables, member
function parameters, and local variables.
* src/roff/troff/env.h (class environment):
* src/roff/troff/env.cpp (class pending_output_line)
(environment::output, environment::newline)
(environment::output_line, environment::possibly_break_line):
(environment::construct_format_state, environment::do_break):
Demote `was_centered` from `int` to `bool`.
(environment::newline): Assign Boolean literals to variables of
type `bool`.
(class pending_output_line) [WIDOW_CONTROL]: Update prototype of
`environment::output` friend declaration.
Comment out parameter names in prototypes, in a compromise with the
Stroustrup-style C++ used in most of groff.
---
ChangeLog | 11 +++++++++++
src/roff/troff/env.cpp | 22 +++++++++++-----------
src/roff/troff/env.h | 13 ++++++++-----
3 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d325e5765..c981f2918 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,17 @@
(pending_output_line::pending_output_line): Demote parameter
`nf` from `int` to `bool`.
+ * src/roff/troff/env.h (class environment):
+ * src/roff/troff/env.cpp (class pending_output_line)
+ (environment::output, environment::newline)
+ (environment::output_line, environment::possibly_break_line):
+ (environment::construct_format_state, environment::do_break):
+ Demote `was_centered` from `int` to `bool`.
+ (environment::newline): Assign Boolean literals to variables of
+ type `bool`.
+ (class pending_output_line) [WIDOW_CONTROL]: Update prototype of
+ `environment::output` friend declaration.
+
2024-04-24 G. Branden Robinson <[email protected]>
* src/roff/troff/env.cpp (tab_stops::to_string)
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 7c94178c4..9b66030e9 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -80,7 +80,7 @@ int translate_space_to_dummy = 0;
class pending_output_line {
node *nd;
bool suppress_filling;
- int was_centered;
+ bool was_centered;
vunits vs;
vunits post_vs;
hunits width;
@@ -98,7 +98,7 @@ public:
#ifdef WIDOW_CONTROL
friend void environment::mark_last_line();
friend void environment::output(node *, bool, vunits, vunits, hunits,
- int);
+ bool);
#endif /* WIDOW_CONTROL */
};
@@ -140,7 +140,7 @@ int pending_output_line::output()
void environment::output(node *nd, bool suppress_filling,
vunits vs, vunits post_vs,
- hunits width, int was_centered)
+ hunits width, bool was_centered)
{
#ifdef WIDOW_CONTROL
while (pending_lines) {
@@ -1796,7 +1796,7 @@ void environment::interrupt()
void environment::newline()
{
- int was_centered = 0;
+ bool was_centered = false;
if (underline_lines > 0) {
if (--underline_lines == 0) {
prev_fontno = fontno;
@@ -1835,7 +1835,7 @@ void environment::newline()
if (x > H0)
saved_indent += x/2;
to_be_output = line;
- was_centered = 1;
+ was_centered = true;
to_be_output_width = width_total;
line = 0;
}
@@ -1875,7 +1875,7 @@ void environment::newline()
}
}
-void environment::output_line(node *n, hunits width, int was_centered)
+void environment::output_line(node *n, hunits width, bool was_centered)
{
prev_text_length = width;
if (margin_character_flags) {
@@ -2200,7 +2200,7 @@ static void distribute_space(node *n, int nspaces, hunits
desired_space,
void environment::possibly_break_line(int start_here, int forced)
{
- int was_centered = center_lines > 0;
+ bool was_centered = center_lines > 0;
if (!fill || current_tab || current_field || dummy)
return;
while (line != 0
@@ -2230,7 +2230,7 @@ void environment::possibly_break_line(int start_here, int
forced)
break;
case ADJUST_CENTER:
saved_indent += (target_text_length - bp->width)/2;
- was_centered = 1;
+ was_centered = true;
break;
case ADJUST_RIGHT:
saved_indent += target_text_length - bp->width;
@@ -2410,7 +2410,7 @@ statem *environment::construct_state(int only_eol)
return NULL;
}
-void environment::construct_format_state(node *n, int was_centered,
+void environment::construct_format_state(node *n, bool was_centered,
int filling)
{
if (is_html) {
@@ -2462,7 +2462,7 @@ extern int global_diverted_space;
void environment::do_break(bool want_adjustment)
{
- int was_centered = 0;
+ bool was_centered = false;
if (curdiv == topdiv && topdiv->before_first_page) {
topdiv->begin_page();
return;
@@ -2491,7 +2491,7 @@ void environment::do_break(bool want_adjustment)
switch (adjust_mode) {
case ADJUST_CENTER:
saved_indent += (target_text_length - width_total)/2;
- was_centered = 1;
+ was_centered = true;
break;
case ADJUST_RIGHT:
saved_indent += target_text_length - width_total;
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index bf5588018..52e487703 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -232,9 +232,11 @@ class environment {
tab_type distance_to_next_tab(hunits *);
tab_type distance_to_next_tab(hunits *distance, hunits *leftpos);
void start_line();
- void output_line(node *, hunits, int);
- void output(node *nd, bool suppress_filling, vunits vs,
- vunits post_vs, hunits width, int was_centered);
+ void output_line(node * /* nd */, hunits /* width */,
+ bool /* was_centered */);
+ void output(node * /* nd */, bool /* suppress_filling */,
+ vunits /* vs */, vunits /* post_vs */, hunits /* width */,
+ bool /* was_centered */);
void output_title(node *nd, bool suppress_filling, vunits vs,
vunits post_vs, hunits width);
#ifdef WIDOW_CONTROL
@@ -363,10 +365,11 @@ public:
const char *get_point_size_string();
const char *get_requested_point_size_string();
void output_pending_lines();
- void construct_format_state(node *n, int was_centered, int fill);
+ void construct_format_state(node * /* nd */, bool /* was_centered */,
+ int /* fill */);
void construct_new_line_state(node *n);
void dump_troff_state();
-
+
friend void title_length();
friend void space_size();
friend void fill();
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit