gbranden pushed a commit to branch master
in repository groff.
commit 6469e004b219f35786e02d886d56808bba846cee
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Mar 16 09:35:30 2025 -0500
[troff]: Fix logic error.
* src/roff/troff/node.cpp (suppress_node::dump_properties): JSON-encode
`position` member variable of this node type.
(draw_node::dump_properties): JSON-encode `gcol` and `fcol`
member variables of this node type.
Problem introduced yesterday with landing of new JSON encoding feature.
---
ChangeLog | 10 ++++++++++
src/roff/troff/node.cpp | 21 +++++++++++++++------
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b072ea14a..da7ce7e94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2025-03-16 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/node.cpp (suppress_node::dump_properties):
+ JSON-encode `position` member variable of this node type.
+ (draw_node::dump_properties): JSON-encode `gcol` and `fcol`
+ member variables of this node type.
+
+ Problem introduced yesterday with landing of new JSON encoding
+ feature.
+
2025-03-16 G. Branden Robinson <[email protected]>
[libgroff]: Fix logic error when encoding characters ", \, and /
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index b02ce00b9..de5c8e4c3 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -4246,10 +4246,17 @@ void suppress_node::dump_properties()
fprintf(stderr, ", \"is_on\": %d", is_on);
fprintf(stderr, ", \"emit_limits\": %s",
emit_limits ? "true" : "false");
- if (filename.contents() != 0 /* nullptr */)
- fprintf(stderr, ", \"filename\": \"%s\"", filename.contents());
- if (position != '\0')
- fprintf(stderr, ", \"position\": \"%c\"", position);
+ if (filename.contents() != 0 /* nullptr */) {
+ fputs(", \"filename\": ", stderr);
+ filename.json_dump();
+ }
+ fputs(", \"position\": \"", stderr);
+ json_char jc = json_encode_char(position);
+ // Write out its JSON representation by character by character to
+ // keep libc string functions from interpreting C escape sequences.
+ for (size_t i = 0; i < jc.len; i++)
+ fputc(jc.buf[i], stderr);
+ fputc('\"', stderr);
fprintf(stderr, ", \"image_id\": %d", image_id);
fflush(stderr);
}
@@ -4875,8 +4882,10 @@ void draw_node::dump_properties()
fprintf(stderr, ", \"code\": \"%c\"", code);
fprintf(stderr, ", \"npoints\": %d", npoints);
fprintf(stderr, ", \"font_size\": %d", sz.to_units());
- fprintf(stderr, ", \"stroke_color\": \"%s\"", gcol->nm.contents());
- fprintf(stderr, ", \"fill_color\": \"%s\"", fcol->nm.contents());
+ fputs(", \"stroke color\": ", stderr);
+ gcol->nm.json_dump();
+ fputs(", \"fill color\": ", stderr);
+ fcol->nm.json_dump();
fprintf(stderr, ", \"point\": \"(%d, %d)\"",
point->h.to_units(), point->v.to_units());
fflush(stderr);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit