gbranden pushed a commit to branch master
in repository groff.
commit b4696db998eed888954b239cd996070dbfcdc097
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Sep 17 19:38:41 2025 -0500
[troff]: Refactor `asciify` internals. (2/3)
* src/roff/troff/input.cpp (asciify_macro): When asciifying a node in a
macro/string/diversion, copy the node first, asciify the copy (which
in many cases produces nothing), and delete the original. This should
be less wasteful of memory, as there's no need to carry around node
data that is unrepresentable as text in an irreversibly transformed
macro/string/diversion.
---
ChangeLog | 6 ++++++
src/roff/troff/input.cpp | 7 +++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 27320028a..5c743a514 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -34,6 +34,12 @@
one, as seen in "om.tmac" and "e.tmac") is to convert strings or
diversions into PDF bookmarks or HTML URLs that are embedded in
a document as metadata or markup, not as formatted text.
+ * src/roff/troff/input.cpp (asciify_macro): When asciifying a
+ node in a macro/string/diversion, copy the node first, asciify
+ the copy (which in many cases produces nothing), and delete the
+ original. This should be less wasteful of memory, as there's no
+ need to carry around node data that is unrepresentable as text
+ in an irreversibly transformed macro/string/diversion.
2025-09-18 G. Branden Robinson <[email protected]>
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 568dac9c8..1a347de82 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5541,8 +5541,11 @@ void asciify_macro()
break;
if (c != 0)
am.append(c);
- else
- nd->asciify(&am);
+ else {
+ node *newnd = nd->copy();
+ newnd->asciify(&am);
+ delete nd;
+ }
}
*m = am;
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit