gbranden pushed a commit to branch master
in repository groff.

commit 1a33ff617ccd5b6f6f43a16a215e9eb3847f6952
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Sun Mar 2 12:51:35 2025 -0600

    [troff]: Add new constructor for `node` type.
    
    ...permitting `is_special` member variable to be initialized in
    initializer lists.
    
    * src/roff/troff/node.h (struct node, node::node): Do it.
    * src/roff/troff/node.cpp (device_extension_node::device_extension_node)
      (suppress_node::suppress_node): Migrate constructors of derived
      classes to it where applicable.
---
 ChangeLog               | 12 ++++++++++++
 src/roff/troff/node.cpp | 16 +++++++---------
 src/roff/troff/node.h   | 12 ++++++++++++
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bd21ecc59..193150596 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2025-03-02  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       [troff]: Add new constructor for `node` type, permitting
+       `is_special` member variable to be initialized in initializer
+       lists.
+
+       * src/roff/troff/node.h (struct node, node::node): Do it.
+       * src/roff/troff/node.cpp
+       (device_extension_node::device_extension_node)
+       (suppress_node::suppress_node): Migrate constructors of derived
+       classes to it where applicable.
+
 2025-03-02  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        * src/roff/troff/node.h (node::node): Fix code style nit;
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 507b21bf2..576bfbd5a 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -3926,7 +3926,8 @@ int node::interpret(macro *)
 }
 
 device_extension_node::device_extension_node(const macro &m, bool b)
-: mac(m), lacks_command_prefix(b)
+: node(0 /* nullptr */, 0 /* nullptr */, 0, true), mac(m),
+  lacks_command_prefix(b)
 {
   font_size fs = curenv->get_font_size();
   int char_height = curenv->get_char_height();
@@ -3937,17 +3938,15 @@ device_extension_node::device_extension_node(const 
macro &m, bool b)
     tf = tf->get_plain();
   gcol = curenv->get_stroke_color();
   fcol = curenv->get_fill_color();
-  is_special = 1;
 }
 
 device_extension_node::device_extension_node(const macro &m, tfont *t,
                           color *gc, color *fc,
                           statem *s, int divlevel,
                           bool b)
-: node(0, s, divlevel), mac(m), tf(t), gcol(gc), fcol(fc),
-  lacks_command_prefix(b)
+: node(0 /* nullptr */, s, divlevel, true), mac(m), tf(t), gcol(gc),
+  fcol(fc), lacks_command_prefix(b)
 {
-  is_special = 1;
 }
 
 bool device_extension_node::is_same_as(node *n)
@@ -4018,9 +4017,9 @@ suppress_node::suppress_node(int on_or_off, int 
issue_limits)
 }
 
 suppress_node::suppress_node(symbol f, char p, int id)
-: is_on(2), emit_limits(0), filename(f), position(p), image_id(id)
+: node(0 /* nullptr */, 0 /* nullptr */, 0, true), is_on(2),
+  emit_limits(0), filename(f), position(p), image_id(id)
 {
-  is_special = 1;
 }
 
 suppress_node::suppress_node(int issue_limits, int on_or_off,
@@ -4054,9 +4053,8 @@ node *suppress_node::copy()
 /* tag_node */
 
 tag_node::tag_node()
-: delayed(0)
+: node(0 /* nullptr */, 0 /* nullptr */, 0, true), delayed(false)
 {
-  is_special = 1;
 }
 
 tag_node::tag_node(string s, int delay)
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index a56714777..32418065e 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -59,6 +59,7 @@ struct node {
   node();
   node(node *);
   node(node *, statem *, int);
+  node(node *, statem *, int, bool);
   node *add_char(charinfo *, environment *, hunits *, int *,
                 node ** /* glyph_comp_np */ = 0 /* nullptr */);
 
@@ -144,6 +145,17 @@ inline node::node(node *n, statem *s, int divlevel)
     state = 0 /* nullptr */;
 }
 
+inline node::node(node *n, statem *s, int divlevel, bool special)
+: next(n), last(0 /* nullptr */),
+  push_state(0 /* nullptr */),
+  div_nest_level(divlevel), is_special(special)
+{
+  if (s != 0 /* nullptr */)
+    state = new statem(s);
+  else
+    state = 0 /* nullptr */;
+}
+
 inline node::~node()
 {
   if (state != 0 /* nullptr */)

_______________________________________________
groff-commit mailing list
groff-commit@gnu.org
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to