gbranden pushed a commit to branch master
in repository groff.
commit 2a182b27792cbda74235fe10fe792464f0cfeef8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Feb 24 18:50:04 2025 -0600
[troff]: Fix Savannah #66815.
Implement approximate (`troff -a`) output of zero-width nodes (these are
constructed from `\Z` escape sequences, and might be better termed
"drawing position resetting nodes").
* src/roff/troff/node.h (class zero_width_node): Declare `ascii_print`
member function.
* src/roff/troff/node.cpp (ascii_print_node_list): New static helper
function iterates a node list, calling each of its elements'
`ascii_print()` member functions.
(zero_width_node::ascii_print): New member function calls the
foregoing.
Fixes <https://savannah.gnu.org/bugs/?66815>. Thanks to Dave
Kemper for the report. Problem appears to date back to groff's birth.
Before:
$ printf '\\Z@abc\\h#6n#@def\n' | ~/groff-1.23.0/bin/groff -a
<beginning of page>
def
Now:
$ printf '\\Z@abc\\h#6n#@def\n' | ./build/test-groff -a
<beginning of page>
abc def
The new behavior aligns better with that of Heirloom Doctools troff.
---
ChangeLog | 19 +++++++++++++++++++
src/roff/troff/node.cpp | 14 ++++++++++++++
src/roff/troff/node.h | 3 ++-
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index e7665e7bf..05d4eaeae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2025-02-24 G. Branden Robinson <[email protected]>
+
+ Implement approximate (`troff -a`) output of zero-width nodes
+ {these are constructed from `\Z` escape sequences, and might be
+ better termed "drawing position resetting nodes"}.
+
+ * src/roff/troff/node.h (class zero_width_node): Declare
+ `ascii_print` member function.
+
+ * src/roff/troff/node.cpp (ascii_print_node_list): New static
+ helper function iterates a node list, calling each of its
+ elements' `ascii_print()` member functions.
+ (zero_width_node::ascii_print): New member function calls the
+ foregoing.
+
+ Fixes <https://savannah.gnu.org/bugs/?66815>. Thanks to Dave
+ Kemper for the report. Problem appears to date back to groff's
+ birth.
+
2025-02-24 G. Branden Robinson <[email protected]>
* src/roff/troff/node.cpp: Fix code style nits.
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 4e8d69cdf..0edd47644 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -3531,6 +3531,15 @@ void vline_node::vertical_extent(vunits *min, vunits
*max)
/* ascii_print methods */
+static void ascii_print_node_list(ascii_output_file *ascii, node *n)
+{
+ node *nn = n;
+ while(nn != 0 /* nullptr */) {
+ nn->ascii_print(ascii);
+ nn = nn->next;
+ }
+}
+
static void ascii_print_reverse_node_list(ascii_output_file *ascii, node *n)
{
if (0 /* nullptr */ == n)
@@ -3572,6 +3581,11 @@ void
space_char_hmotion_node::ascii_print(ascii_output_file *ascii)
ascii->outc(' ');
}
+void zero_width_node::ascii_print(ascii_output_file *out)
+{
+ ascii_print_node_list(out, n);
+}
+
/* asciify methods */
void node::asciify(macro *m)
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 4e1b15ce2..fe96fa1c6 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
Written by James Clark ([email protected])
This file is part of groff.
@@ -461,6 +461,7 @@ public:
~zero_width_node();
node *copy();
void tprint(troff_output_file *);
+ void ascii_print(ascii_output_file *);
bool is_same_as(node *);
const char *type();
bool causes_tprint();
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit