gbranden pushed a commit to branch master
in repository groff.
commit c85002c38ffb827ad13936ba38d6c94a09db0155
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Aug 28 16:15:27 2024 -0500
src/roff/troff/node.{h,cpp}: Trivially refactor.
* src/roff/troff/node.cpp (class troff_output_file): Boolify final
argument to `start_special` member function.
(troff_output_file::start_special): Rename argument from
`no_init_string` to `omit_command_prefix` and demote it from `int` to
`bool`.
(special_node::tprint_start): Update call site to use new name.
* src/roff/troff/node.h (class special_node): Rename member variable
from `no_init_string` to `lacks_command_prefix` and demote it from
`int` to `bool`.
* src/roff/troff/node.cpp (special_node::special_node): Update
constructor initialization lists.
(special_node::is_same_as): Update to use new name.
(special_node::copy): Update constructor call.
(special_node::tprint): Rename argument to `start_special` call on
`troff_output_file` object: here is where the `lacks_command_prefix`
property of the `special_node` becomes an instruction to the
`troff_output_file` object to omit that prefix.
---
ChangeLog | 22 ++++++++++++++++++++++
src/roff/troff/node.cpp | 34 +++++++++++++++++++---------------
src/roff/troff/node.h | 10 ++++++----
3 files changed, 47 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 981cf180a..b35d4de6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-08-28 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/node.cpp (class troff_output_file): Boolify
+ final argument to `start_special` member function.
+ (troff_output_file::start_special): Rename argument from
+ `no_init_string` to `omit_command_prefix` and demote it from
+ `int` to `bool`.
+ (special_node::tprint_start): Update call site to use new name.
+
+ * src/roff/troff/node.h (class special_node): Rename member
+ variable from `no_init_string` to `lacks_command_prefix` and
+ demote it from `int` to `bool`.
+ * src/roff/troff/node.cpp (special_node::special_node): Update
+ constructor initialization lists.
+ (special_node::is_same_as): Update to use new name.
+ (special_node::copy): Update constructor call.
+ (special_node::tprint): Rename argument to `start_special` call
+ on `troff_output_file` object: here is where the
+ `lacks_command_prefix` property of the `special_node` becomes an
+ instruction to the `troff_output_file` object to omit that
+ prefix.
+
2024-08-28 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp: Boolify `troff_output_file` class.
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index f66d21dc3..90ab9742b 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -824,7 +824,9 @@ public:
void right(hunits);
void down(vunits);
void moveto(hunits, vunits);
- void start_special(tfont *, color *, color *, int = 0);
+ void start_special(tfont * /* tf */,
+ color * /* gcol */, color * /* fcol */,
+ bool /* omit_command_prefix */ = false);
void start_special();
void special_char(unsigned char c);
void end_special();
@@ -883,15 +885,16 @@ inline void troff_output_file::put(unsigned int i)
put_string(ui_to_a(i), fp);
}
-void troff_output_file::start_special(tfont *tf, color *gcol, color *fcol,
- int no_init_string)
+void troff_output_file::start_special(tfont *tf, color *gcol,
+ color *fcol,
+ bool omit_command_prefix)
{
set_font(tf);
glyph_color(gcol);
fill_color(fcol);
flush_tbuf();
do_motion();
- if (!no_init_string)
+ if (!omit_command_prefix)
put("x X ");
}
@@ -3883,8 +3886,8 @@ int node::interpret(macro *)
return 0;
}
-special_node::special_node(const macro &m, int n)
-: mac(m), no_init_string(n)
+special_node::special_node(const macro &m, bool b)
+: mac(m), lacks_command_prefix(b)
{
font_size fs = curenv->get_font_size();
int char_height = curenv->get_char_height();
@@ -3901,20 +3904,21 @@ special_node::special_node(const macro &m, int n)
special_node::special_node(const macro &m, tfont *t,
color *gc, color *fc,
statem *s, int divlevel,
- int n)
+ bool b)
: node(0, s, divlevel), mac(m), tf(t), gcol(gc), fcol(fc),
- no_init_string(n)
+ lacks_command_prefix(b)
{
is_special = 1;
}
bool special_node::is_same_as(node *n)
{
- return mac == ((special_node *)n)->mac
- && tf == ((special_node *)n)->tf
- && gcol == ((special_node *)n)->gcol
- && fcol == ((special_node *)n)->fcol
- && no_init_string == ((special_node *)n)->no_init_string;
+ return ((mac == ((special_node *)n)->mac)
+ && (tf == ((special_node *)n)->tf)
+ && (gcol == ((special_node *)n)->gcol)
+ && (fcol == ((special_node *)n)->fcol)
+ && (lacks_command_prefix
+ == ((special_node *)n)->lacks_command_prefix));
}
const char *special_node::type()
@@ -3940,12 +3944,12 @@ bool special_node::is_tag()
node *special_node::copy()
{
return new special_node(mac, tf, gcol, fcol, state, div_nest_level,
- no_init_string);
+ lacks_command_prefix);
}
void special_node::tprint_start(troff_output_file *out)
{
- out->start_special(tf, gcol, fcol, no_init_string);
+ out->start_special(tf, gcol, fcol, lacks_command_prefix);
}
void special_node::tprint_char(troff_output_file *out, unsigned char c)
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 5a1b13e14..773e72f6f 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -545,14 +545,16 @@ class special_node : public node {
tfont *tf;
color *gcol;
color *fcol;
- int no_init_string;
+ bool lacks_command_prefix;
void tprint_start(troff_output_file *);
void tprint_char(troff_output_file *, unsigned char);
void tprint_end(troff_output_file *);
public:
- special_node(const macro &, int /* n */ = 0);
- special_node(const macro &, tfont *, color *, color *, statem *, int,
- int /* n */ = 0);
+ special_node(const macro & /* m */,
+ bool /* lacks_command_prefix */ = false);
+ special_node(const macro & /* m */, tfont * /* tf */,
+ color * /* gcol */, color * /* fcol */, statem * /* s */,
+ int divlevel, bool /* lacks_command_prefix */ = false);
node *copy();
void tprint(troff_output_file *);
bool is_same_as(node *);
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit