gbranden pushed a commit to branch master
in repository groff.

commit 40b65421523ddc9eea23523a08ce05725c3769a4
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Sep 11 09:53:32 2025 -0500

    [troff]: Stop asciifying horiz motions as tabs.
    
    * src/roff/troff/node.cpp (hmotion_node::asciify): Stop asciifying a
      horizontal motion node that was a tab character as a tab; instead
      delete it like any other horizontal motion.  We have no semantics for
      tab characters in, for example, the parameters of device extension
      commands.  Ensure that the node object is deleted on every path
      through the function (now trivial).
    
    * src/roff/groff/tests/asciify-request-works.sh: Add test cases for
      transformation of nodes produced by `\t` and `\h` escape sequences.
    
    Also annotate the remaining reason for the `hmotion_node` class's
    `was_tab` member variable to exist.
---
 ChangeLog                                     | 13 +++++++++++++
 src/roff/groff/tests/asciify-request-works.sh |  9 ++++++++-
 src/roff/troff/node.cpp                       |  9 ++-------
 src/roff/troff/node.h                         |  2 +-
 4 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0d0fe83d3..e4f905718 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2025-09-09  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/node.cpp (hmotion_node::asciify): Stop
+       asciifying a horizontal motion node that was a tab character as
+       a tab; instead delete it like any other horizontal motion.  We
+       have no semantics for tab characters in, for example, the
+       parameters of device extension commands.  Ensure that the node
+       object is deleted on every path through the function (now
+       trivial).
+       * src/roff/groff/tests/asciify-request-works.sh: Add test cases
+       for transformation of nodes produced by `\t` and `\h` escape
+       sequences.
+
 2025-09-09  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/node.cpp: Add more `assert()`ions and validity
diff --git a/src/roff/groff/tests/asciify-request-works.sh 
b/src/roff/groff/tests/asciify-request-works.sh
index aba424f0a..4716dfd6d 100755
--- a/src/roff/groff/tests/asciify-request-works.sh
+++ b/src/roff/groff/tests/asciify-request-works.sh
@@ -35,7 +35,8 @@ A#[dq]#[e aa]#[u00E1]#[u0106]i#[fl]o#[Fl]#[Z]
 1@#&2@#)3@#c
 4@#c
 .tag foo
-5@#X"bar"6@#v".5v"7@
+.ds tab #t#"
+5@#X"bar"6@#v".5v"7@#*[tab]8@#h"2m"9@
 .ec
 .br
 .box
@@ -92,6 +93,12 @@ echo "$output" | grep -q "5@6" || wail
 echo "checking textification of vertical motion escape sequence" >&2
 echo "$output" | grep -q "6@7" || wail
 
+echo "checking textification of (tab) horizontal motion escape sequence" >&2
+echo "$output" | grep -q "7@8" || wail
+
+echo "checking textification of (plain) horizontal motion escape sequence" >&2
+echo "$output" | grep -q "8@9" || wail
+
 test -z "$fail"
 
 # vim:set autoindent expandtab shiftwidth=2 tabstop=2 textwidth=72:
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 9665d0581..640d71ca6 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -3968,14 +3968,9 @@ void left_italic_corrected_node::asciify(macro *m)
   delete this;
 }
 
-void hmotion_node::asciify(macro *m)
+void hmotion_node::asciify(macro *)
 {
-  if (was_tab) {
-    m->append('\t');
-    delete this;
-  }
-  else
-    m->append(this);
+  delete this;
 }
 
 space_char_hmotion_node::space_char_hmotion_node(hunits i, color *c,
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index 0227486ff..1fc905314 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -346,7 +346,7 @@ public:
 class hmotion_node : public node {
 protected:
   hunits n;
-  bool was_tab;
+  bool was_tab;                        // needed by `unformat`
   bool unformat;
   color *col;                  /* for grotty */
 public:

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to