gbranden pushed a commit to branch master
in repository groff.

commit b8f941ebc44897a6ef798eb20b1d01abf81f6816
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Sat Mar 15 14:49:13 2025 -0500

    [troff]: Implement recursive node dumping (8h/9).
    
    Derive class `bracket_node` from struct `container_node`.
    
    * src/roff/troff/node.h (class bracket_node): Do it.  Drop
      pointer-to-node member variable and declaration of destructor.
    
    * src/roff/troff/node.cpp (bracket_node::bracket_node): Migrate
      constructors to use new base class.
    
      (bracket_node::~bracket_node): Drop; our base class handles
      destruction of contained node(s).
    
    Changes `pline` request output as follows.
    
    -{"type": "bracket_node", "diversion level": 0, "is_special_node": false, 
"max_width": 5640},
    +{"type": "bracket_node", "diversion level": 0, "is_special_node": false, 
"max_width": 5640, "contents": [{"type": "glyph_node", "diversion level": 0, 
"is_special_node": false, "character": "+"}, {"type": "glyph_node", "diversion 
level": 0, "is_special_node": false, "character": "|"}, {"type": "glyph_node", 
"diversion level": 0, "is_special_node": false, "character": "+"}]},
---
 ChangeLog               | 12 ++++++++++++
 src/roff/troff/node.cpp | 10 ++--------
 src/roff/troff/node.h   |  5 +----
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a4ced42df..f1bcf224a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2025-03-15  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       [troff]: Derive class `bracket_node` from struct
+       `container_node`.
+
+       * src/roff/troff/node.h (class bracket_node): Do it.  Drop
+       pointer-to-node member variable and declaration of destructor.
+       * src/roff/troff/node.cpp (bracket_node::bracket_node): Migrate
+       constructors to use new base class.
+       (bracket_node::~bracket_node): Drop; our base class handles
+       destruction of contained node(s).
+
 2025-03-15  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        [troff]: Derive class `overstrike_node` from struct
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 3d485efeb..6df4bccd5 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -3343,13 +3343,12 @@ hunits overstrike_node::width()
 }
 
 bracket_node::bracket_node()
-: nodes(0 /* nullptr */), max_width(H0)
+: container_node(0 /* nullptr */), max_width(H0)
 {
 }
 
 bracket_node::bracket_node(statem *s, int divlevel)
-: node(0 /* nullptr */, s, divlevel), nodes(0 /* nullptr */),
-  max_width(H0)
+: container_node(0 /* nullptr */, s, divlevel), max_width(H0)
 {
 }
 
@@ -3360,11 +3359,6 @@ void bracket_node::dump_properties()
   fflush(stderr);
 }
 
-bracket_node::~bracket_node()
-{
-  delete_node_list(nodes);
-}
-
 node *bracket_node::copy()
 {
   bracket_node *on = new bracket_node(state, div_nest_level);
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index a03c02a0f..3a9a92b71 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -553,14 +553,11 @@ public:
   void dump_properties();
 };
 
-// TODO: Derive from abstract class `container_node`.
-class bracket_node : public node {
-  node *nodes;
+class bracket_node : public container_node {
   hunits max_width;
 public:
   bracket_node();
   bracket_node(statem *, int);
-  ~bracket_node();
   node *copy();
   void tprint(troff_output_file *);
   void bracket(node *);        // add another node to be overstruck

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

Reply via email to