gbranden pushed a commit to branch master
in repository groff.

commit d4d678e097c3e0b10d0e26f0e306012d66083daa
Author: G. Branden Robinson <g.branden.robin...@gmail.com>
AuthorDate: Sun Mar 2 21:59:28 2025 -0600

    [troff]: Implement recursive node dumping (3/9).
    
    * src/roff/troff/node.cpp (class composite_node): Rename member function
      `dump_node()` to `dump_properties()`, altering its purpose.
    
      (composite_node::dump_node): Rename this...
      (composite_node::dump_properties): ...to this.  Now we override
      a different function, and can ditch repetitious code that
      reported properties of the base class.
    
    Also drop now-stale comments.
    
    Changes `pline` request output as follows (and as planned with
    properties of the base class--except for MTSM/HTML "state"
    stuff--preceding those of the derived class).
    
    -{"type": "composite_node", "character": "\\Fl", "diversion level": 0, 
"is_special_node": false},
    +{"type": "composite_node", "diversion level": 0, "is_special_node": false, 
"special character": "Fl"},
---
 ChangeLog               | 10 ++++++++++
 src/roff/troff/node.cpp | 20 +++-----------------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8d8769a3b..f53b11080 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-03-02  G. Branden Robinson <g.branden.robin...@gmail.com>
+
+       * src/roff/troff/node.cpp (class composite_node): Rename member
+       function `dump_node()` to `dump_properties()`, altering its
+       purpose.
+       (composite_node::dump_node): Rename this...
+       (composite_node::dump_properties): ...to this.  Now we override
+       a different function, and can ditch repetitious code that
+       reported properties of the base class.
+
 2025-03-02  G. Branden Robinson <g.branden.robin...@gmail.com>
 
        * src/roff/troff/node.h (struct node): Add new virtual member
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index a3637291c..5b6b66b05 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -4390,7 +4390,7 @@ public:
   bool is_tag();
   void vertical_extent(vunits *, vunits *);
   vunits vertical_width();
-  void dump_node();
+  void dump_properties();
 };
 
 composite_node::composite_node(node *p, charinfo *c, tfont *t, statem *s,
@@ -5033,11 +5033,9 @@ void composite_node::tprint(troff_output_file *out)
     out->right(track_kern);
 }
 
-// XXX: This and `glyph_node::dump_node()` are identical.  C++
-// presumably has several different solutions for this.  Pick one.
-void composite_node::dump_node()
+void composite_node::dump_properties()
 {
-  fprintf(stderr, "{\"type\": \"%s\"", type());
+  node::dump_properties();
   // GNU troff multiplexes the distinction of ordinary vs. special
   // characters though the special character code zero.
   unsigned char c = ci->get_ascii_code();
@@ -5061,18 +5059,6 @@ void composite_node::dump_node()
     fputs(", \"special character\": ", stderr);
     ci->nm.json_dump();
   }
-  fprintf(stderr, ", \"diversion level\": %d", div_nest_level);
-  fprintf(stderr, ", \"is_special_node\": %s",
-         is_special ? "true" : "false");
-  if (push_state) {
-    fputs(", \"push_state\": ", stderr);
-    push_state->display_state();
-  }
-  if (state) {
-    fputs(", \"state\": ", stderr);
-    state->display_state();
-  }
-  fputs("}", stderr);
   fflush(stderr);
 }
 

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

Reply via email to