gbranden pushed a commit to branch master
in repository groff.
commit 9c4e2c8c6a26ebfb03865fb05dc121c77a553936
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Mar 9 21:14:19 2026 -0500
[troff]: Fix Savannah #68132.
* src/roff/troff/input.cpp (do_translate): Stop throwing assertions if
one of the participants (source or destination) in a character
translation is a non-character. Historical documents like Ritchie's
"C Reference Manual" from Sixth Edition Unix (1975) did things like
`.tr ~\|`. This is no longer a worthwhile idiom--if indeed it ever
was, since strings were available even then, but especially not since
1990 or so with GNU troff's `char` and related requests--but we should
not abort the formatter on encountering them. Actually _supporting_
such translations, in compatibility mode only, is under consideration
for groff 1.25. Throw error when encountering `tr` requests that
attempt to operate on non-characters outside of compatibility mode.
Fixes <https://savannah.gnu.org/bugs/?68132>. Thanks to Clem Cole for
the report. Problem introduced by me in 52025b06f5, 21 November, in the
course of adding many assertions to GNU troff to try to smoke out
transitions into invalid formatter state and code that should be
unreachable but isn't. This instance fooled me because we did nothing
useful (nor consistent with AT&T troff behavior) with the non-character
translation participant; see above regarding future plans.
ANNOUNCE: Acknowledge Clem.
---
ANNOUNCE | 1 +
ChangeLog | 25 +++++++++++++++++++++++++
src/roff/troff/input.cpp | 18 ++++++++++++++----
3 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/ANNOUNCE b/ANNOUNCE
index d26210819..b8c3bcdc9 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -208,5 +208,6 @@ of this release.
similar from the contrib/ change log files may also be necessary. ]]
Bjarni Ingi Gislason
+Clem Cole
Peng Zhang
Rocket Ma
diff --git a/ChangeLog b/ChangeLog
index c43afea90..7f6e37fc1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2026-03-09 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (do_translate): Stop throwing
+ assertions if one of the participants (source or destination) in
+ a character translation is a non-character. Historical
+ documents like Ritchie's "C Reference Manual" from Sixth Edition
+ Unix (1975) did things like `.tr ~\|`. This is no longer a
+ worthwhile idiom--if indeed it ever was, since strings were
+ available even then, but especially not since 1990 or so with
+ GNU troff's `char` and related requests--but we should not abort
+ the formatter on encountering them. Actually _supporting_ such
+ translations, in compatibility mode only, is under consideration
+ for groff 1.25. Throw error when encountering `tr` requests
+ that attempt to operate on non-characters outside of
+ compatibility mode.
+
+ Fixes <https://savannah.gnu.org/bugs/?68132>. Thanks to Clem
+ Cole for the report. Problem introduced by me in 52025b06f5, 21
+ November, in the course of adding many assertions to GNU troff
+ to try to smoke out transitions into invalid formatter state and
+ code that should be unreachable but isn't. This instance fooled
+ me because we did nothing useful (nor consistent with AT&T troff
+ behavior) with the non-character translation participant; see
+ above regarding future plans.
+
2026-03-09 G. Branden Robinson <[email protected]>
[troff]: Regression-test Savannah #68132.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 1fe5b1631..bef670fd4 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8594,10 +8594,19 @@ static void do_translate(bool transparently, bool
as_input)
tok.next();
continue;
}
+ // The semantics of character translation operations on non-
+ // characters (space escape sequences) are ill-defined and vary
+ // among troffs; see Savannah #68133.
+ //
+ // TODO: However, documents such as Ritchie's "C Reference Manual"
+ // distributed with Sixth Edition Unix did things like `.tr ^\|`, so
+ // some support should be added, only for those idioms, and only in
+ // compatibility mode.
charinfo *ci1 = tok.get_charinfo(true /* required */);
if (0 /* nullptr */ == ci1) {
- assert(0 == "attempted to use token without charinfo in character"
- " translation request");
+ if (!want_att_compat)
+ error("cannot perform character translation from %1",
+ tok.description());
break;
}
tok.next();
@@ -8621,8 +8630,9 @@ static void do_translate(bool transparently, bool
as_input)
else {
charinfo *ci2 = tok.get_charinfo(true /* required */);
if (0 /* nullptr */ == ci2) {
- assert(0 == "attempted to use token without charinfo in"
- " character translation request");
+ if (!want_att_compat)
+ error("cannot perform character translation to %1",
+ tok.description());
break;
}
if (ci1 == ci2)
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit