gbranden pushed a commit to branch master
in repository groff.
commit 8ab4aa8bec74dbc4d2585c9395968cdfa2720c0d
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Aug 14 13:54:42 2024 -0500
[troff]: Slightly refactor (4/6).
* src/roff/troff/node.h (struct node, class hmotion_node): Boolify.
Demote member function `set_unformat_flag()` and member variable
`unformat` from `int` to `bool`. These could use renaming, but
`make_unformattable() and `is_unformattable` would be terribly
misleading.
* src/roff/troff/node.cpp (node::set_unformat_flag)
(word_space_node::set_unformat_flag)
(vertical_size_node::set_unformat_flag)
(hmotion_node::set_unformat_flag): Demote return type and use Boolean
literals for assignments and return values.
(word_space_node::word_space_node): Use Boolean literal in
constructor's initializer list.
(word_space_node::word_space_node): Update data type in constructor's
argument list.
---
ChangeLog | 15 +++++++++++++++
src/roff/troff/node.cpp | 24 ++++++++++++------------
src/roff/troff/node.h | 23 ++++++++++++-----------
3 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d0668f416..e35ebe9fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -24,6 +24,21 @@
* src/roff/troff/node.cpp (break_char_node::add_self): Demote
`have_space_node` local variable from `int` to `bool`.
+ * src/roff/troff/node.h (struct node, class hmotion_node):
+ Boolify. Demote member function `set_unformat_flag()` and
+ member variable `unformat` from `int` to `bool`. These could
+ use renaming, but `make_unformattable() and `is_unformattable`
+ would be terribly misleading.
+ * src/roff/troff/node.cpp (node::set_unformat_flag)
+ (word_space_node::set_unformat_flag)
+ (vertical_size_node::set_unformat_flag)
+ (hmotion_node::set_unformat_flag): Demote return type and use
+ Boolean literals for assignments and return values.
+ (word_space_node::word_space_node): Use Boolean literal in
+ constructor's initializer list.
+ (word_space_node::word_space_node): Update data type in
+ constructor's argument list.
+
2024-08-14 G. Branden Robinson <[email protected]>
* src/roff/troff/token.h (token:ch()): Return character instead
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 66c5d8b53..b86ca41f6 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -3411,9 +3411,9 @@ vunits vmotion_node::vertical_width()
return n;
}
-int node::set_unformat_flag()
+bool node::set_unformat_flag()
{
- return 1;
+ return true;
}
int node::character_type()
@@ -4418,12 +4418,12 @@ width_list::width_list(width_list *w)
}
word_space_node::word_space_node(hunits d, color *c, width_list *w, node *x)
-: space_node(d, c, x), orig_width(w), unformat(0)
+: space_node(d, c, x), orig_width(w), unformat(false)
{
}
word_space_node::word_space_node(hunits d, int s, color *c,
- width_list *w, int flag, statem *st,
+ width_list *w, bool flag, statem *st,
int divlevel, node *x)
: space_node(d, s, 0, c, st, divlevel, x), orig_width(w), unformat(flag)
{
@@ -4455,10 +4455,10 @@ node *word_space_node::copy()
div_nest_level);
}
-int word_space_node::set_unformat_flag()
+bool word_space_node::set_unformat_flag()
{
- unformat = 1;
- return 1;
+ unformat = true;
+ return true;
}
void word_space_node::tprint(troff_output_file *out)
@@ -5234,9 +5234,9 @@ const char *vertical_size_node::type()
return "vertical_size_node";
}
-int vertical_size_node::set_unformat_flag()
+bool vertical_size_node::set_unformat_flag()
{
- return 0;
+ return false;
}
int vertical_size_node::force_tprint()
@@ -5260,10 +5260,10 @@ const char *hmotion_node::type()
return "hmotion_node";
}
-int hmotion_node::set_unformat_flag()
+bool hmotion_node::set_unformat_flag()
{
- unformat = 1;
- return 1;
+ unformat = true;
+ return true;
}
int hmotion_node::force_tprint()
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index b13261a99..d0650402c 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -64,7 +64,7 @@ struct node {
virtual ~node();
virtual node *copy() = 0;
- virtual int set_unformat_flag();
+ virtual bool set_unformat_flag();
virtual int force_tprint() = 0;
virtual bool is_tag() = 0;
virtual int get_break_code();
@@ -221,8 +221,8 @@ struct width_list {
class word_space_node : public space_node {
protected:
width_list *orig_width;
- unsigned char unformat;
- word_space_node(hunits, int, color *, width_list *, int, statem *,
+ bool unformat;
+ word_space_node(hunits, int, color *, width_list *, bool, statem *,
int, node * /* x */ = 0 /* nullptr */);
public:
word_space_node(hunits, color *, width_list *,
@@ -230,7 +230,7 @@ public:
~word_space_node();
node *copy();
int reread(int *);
- int set_unformat_flag();
+ bool set_unformat_flag();
void tprint(troff_output_file *);
bool is_same_as(node *);
void asciify(macro *);
@@ -315,7 +315,7 @@ public:
void set_vertical_size(vertical_size *);
void asciify(macro *);
node *copy();
- int set_unformat_flag();
+ bool set_unformat_flag();
bool is_same_as(node *);
const char *type();
int force_tprint();
@@ -326,24 +326,25 @@ class hmotion_node : public node {
protected:
hunits n;
unsigned char was_tab;
- unsigned char unformat;
+ bool unformat;
color *col; /* for grotty */
public:
hmotion_node(hunits i, color *c, node *nxt = 0 /* nullptr */)
- : node(nxt), n(i), was_tab(0), unformat(0), col(c) {}
+ : node(nxt), n(i), was_tab(0), unformat(false), col(c) {}
hmotion_node(hunits i, color *c, statem *s, int divlevel,
node *nxt = 0 /* nullptr */)
- : node(nxt, s, divlevel), n(i), was_tab(0), unformat(0), col(c) {}
- hmotion_node(hunits i, int flag1, int flag2, color *c, statem *s,
+ : node(nxt, s, divlevel), n(i), was_tab(0), unformat(false),
+ col(c) {}
+ hmotion_node(hunits i, int flag1, bool flag2, color *c, statem *s,
int divlevel, node *nxt = 0 /* nullptr */)
: node(nxt, s, divlevel), n(i), was_tab(flag1), unformat(flag2),
col(c) {}
- hmotion_node(hunits i, int flag1, int flag2, color *c,
+ hmotion_node(hunits i, int flag1, bool flag2, color *c,
node *nxt = 0 /* nullptr */)
: node(nxt), n(i), was_tab(flag1), unformat(flag2), col(c) {}
node *copy();
int reread(int *);
- int set_unformat_flag();
+ bool set_unformat_flag();
void asciify(macro *);
void tprint(troff_output_file *);
hunits width();
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit