gbranden pushed a commit to branch master in repository groff. commit f15eec72facfa080a1d3044ff39b0c345df4cb0e Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Sat Mar 15 01:51:41 2025 -0500
[troff]: Slightly refactor. * src/roff/troff/node.h: Boolify: demote some class member variables and member function return types from `int` to `bool`. (struct node, class space_node): Update `discardable()` declaration. (class space_node): Update `set` and `was_escape_colon` declarations. (class suppress_node): Update `emit_limits` declaration. * src/roff/troff/node.cpp (space_node::space_node): Use Boolean instead of integer literal in `was_escape_colon` initializer. (space_node::spread_space, space_node::freeze_space) (space_node::is_escape_colon): Use Boolean instead of integer literals when assigning to `bool` member variables. (node::discardable, space_node::discardable): Update return type. (space_node::discardable): Simplify expression. --- ChangeLog | 20 ++++++++++++++++++++ src/roff/troff/node.cpp | 18 +++++++++--------- src/roff/troff/node.h | 10 +++++----- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 726eecd5a..c8fabbf95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2025-03-15 G. Branden Robinson <g.branden.robin...@gmail.com> + + [troff]: Slightly refactor. + + * src/roff/troff/node.h: Boolify: demote some class member + variables and member function return types from `int` to `bool`. + (struct node, class space_node): Update `discardable()` + declaration. + (class space_node): Update `set` and `was_escape_colon` + declarations. + (class suppress_node): Update `emit_limits` declaration. + * src/roff/troff/node.cpp (space_node::space_node): Use Boolean + instead of integer literal in `was_escape_colon` initializer. + (space_node::spread_space, space_node::freeze_space) + (space_node::is_escape_colon): Use Boolean instead of integer + literals when assigning to `bool` member variables. + (node::discardable, space_node::discardable): Update return + type. + (space_node::discardable): Simplify expression. + 2025-03-15 G. Branden Robinson <g.branden.robin...@gmail.com> [troff]: Trivially refactor. diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp index 0c5c6ff80..547b23953 100644 --- a/src/roff/troff/node.cpp +++ b/src/roff/troff/node.cpp @@ -3257,7 +3257,7 @@ bool node::did_space_merge(hunits, hunits, hunits) space_node::space_node(hunits nn, color *c, node *p) -: node(p, 0 /* nullptr */, 0), n(nn), set('\0'), was_escape_colon(0), +: node(p, 0 /* nullptr */, 0), n(nn), set('\0'), was_escape_colon(false), col(c) { } @@ -3323,7 +3323,7 @@ void space_node::spread_space(int *n_spaces, hunits *desired_space) n += extra; } *n_spaces -= 1; - set = 1; + set = true; } } @@ -3333,7 +3333,7 @@ void node::freeze_space() void space_node::freeze_space() { - set = 1; + set = true; } void node::is_escape_colon() @@ -3342,7 +3342,7 @@ void node::is_escape_colon() void space_node::is_escape_colon() { - was_escape_colon = 1; + was_escape_colon = true; } diverted_space_node::diverted_space_node(vunits d, statem *s, @@ -3428,14 +3428,14 @@ int node::overlaps_vertically() return 0; } -int node::discardable() +bool node::discardable() { - return 0; + return false; } -int space_node::discardable() +bool space_node::discardable() { - return set ? 0 : 1; + return !set; } vunits node::vertical_width() @@ -4028,7 +4028,7 @@ suppress_node::suppress_node(int on_or_off, int issue_limits) suppress_node::suppress_node(symbol f, char p, int id) : node(0 /* nullptr */, 0 /* nullptr */, 0, true), is_on(2), - emit_limits(0), filename(f), position(p), image_id(id) + emit_limits(false), filename(f), position(p), image_id(id) { } diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h index 8a08811a9..d503c2e0e 100644 --- a/src/roff/troff/node.h +++ b/src/roff/troff/node.h @@ -88,7 +88,7 @@ struct node { virtual hyphen_list *get_hyphen_list(hyphen_list *, int *); virtual void ascii_print(ascii_output_file *); virtual void asciify(macro *); - virtual int discardable(); + virtual bool discardable(); virtual void spread_space(int *, hunits *); virtual void freeze_space(); virtual void is_escape_colon(); @@ -192,8 +192,8 @@ class space_node : public node { private: protected: hunits n; - char set; - char was_escape_colon; + bool set; + bool was_escape_colon; color *col; /* for grotty */ space_node(hunits, int, int, color *, statem *, int, node * = 0 /* nullptr */); @@ -202,7 +202,7 @@ public: node *copy(); int nspaces(); hunits width(); - int discardable(); + bool discardable(); bool did_space_merge(hunits, hunits, hunits); void freeze_space(); void is_escape_colon(); @@ -581,7 +581,7 @@ public: class suppress_node : public node { int is_on; // three-valued Boolean :-| - int emit_limits; // must we issue extent of the area written out? + bool emit_limits; // must we issue extent of the area written out? symbol filename; char position; int image_id; _______________________________________________ groff-commit mailing list groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit