gbranden pushed a commit to branch master
in repository groff.
commit 7356be024bf0f687b5b2f7d7d956762467635f2b
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Nov 6 03:02:48 2025 -0600
[troff]: Accept more compat mode delimiters (3/3).
* src/roff/troff/input.cpp (token::is_usable_as_delimter): In
compatibility mode, permit control characters as delimiters that DWB
3.3 troff accepts. (Actually, this is slightly overbroad--AT&T troff
does _not_ permit ^A, ^D, ^H, ^I, or ^L. But this stuff is tedious to
test (and the old "use-a-control-character- as-a-delimiter trick" is
commonplace in historical documents, so we really should support it in
at least approximate form).
* src/roff/groff/tests/check-delimiter-validity.sh: Test them.
---
ChangeLog | 12 +++++++++++
src/roff/groff/tests/check-delimiter-validity.sh | 27 ++++++++++++++++++++++++
src/roff/troff/input.cpp | 9 +++++---
3 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ba6950b65..464d0bdc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2025-11-06 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (token::is_usable_as_delimter): In
+ compatibility mode, permit control characters as delimiters that
+ DWB 3.3 troff accepts. (Actually, this is slightly overbroad--
+ AT&T troff does _not_ permit ^A, ^D, ^H, ^I, or ^L. But this
+ stuff is tedious to test (and the old "use-a-control-character-
+ as-a-delimiter trick" is commonplace in historical documents, so
+ we really should support it in at least approximate form).
+
+ * src/roff/groff/tests/check-delimiter-validity.sh: Test them.
+
2025-11-06 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (token::is_usable_as_delimter):
diff --git a/src/roff/groff/tests/check-delimiter-validity.sh
b/src/roff/groff/tests/check-delimiter-validity.sh
index d591718de..a360789aa 100755
--- a/src/roff/groff/tests/check-delimiter-validity.sh
+++ b/src/roff/groff/tests/check-delimiter-validity.sh
@@ -73,6 +73,15 @@ do
echo "$output" | grep -Fqx ___ || wail
done
+for octal in 002 003 005 006 007 177
+do
+ echo "checking validity of control character $octal (octal)" \
+ "as string expression delimiter in compatibility mode" >&2
+ output=$(printf '\\o\'$octal'__\'$octal'__\n' \
+ | "$groff" -C -w delim -T ascii | sed '/^$/d')
+ echo "$output" | grep -qx _.___ || wail
+done
+
for c in A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \
a b c d e f g h i j k l m n o p q r s t u v w x y z \
0 1 2 3 4 5 6 7 8 9 . '|' \
@@ -86,6 +95,15 @@ do
echo "$output" | grep -Fqx '_ _' || wail
done
+for octal in 002 003 005 006 007 177
+do
+ echo "checking validity of control character $octal (octal)" \
+ "as numeric expression delimiter in compatibility mode" >&2
+ output=$(printf '\\o\'$octal'__\'$octal'__\n' \
+ | "$groff" -C -w delim -T ascii | sed '/^$/d')
+ echo "$output" | grep -qx _.___ || wail
+done
+
# 'v' as a conditional expression operator is a vtroff extension, not a
# GNU one. vtroff is also unobtainium in the 21st century. DWB 3.3,
# Plan 9, and Solaris 10 troffs don't treat 'v' specially.
@@ -114,6 +132,15 @@ do
echo "$output" | grep -Fqx ___ || wail
done
+for octal in 002 003 005 006 007 177
+do
+ echo "checking validity of control character $octal (octal)" \
+ "as output comparison delimiter in compatibility mode" >&2
+ output=$(printf '.if \'$octal'@@@\'$octal'@@@\'$octal' ___\n' \
+ | "$groff" -C -w delim -T ascii -P -cbou | sed '/^$/d')
+ echo "$output" | grep -Fqx ___ || wail
+done
+
test -z "$fail"
# vim:set autoindent expandtab shiftwidth=4 tabstop=4 textwidth=72:
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 74a404b60..e72d4e70c 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2769,11 +2769,13 @@ bool token::is_usable_as_delimiter(bool report_error,
assert(context != DELIMITER_GROFF_EXPRESSION);
switch (context) {
case DELIMITER_ATT_STRING_EXPRESSION:
- if (csgraph(c))
+ if (csgraph(c)
+ || (((c > 0) && (c < 012)) || (014 == c) || (0177 == c)))
is_valid = true;
break;
case DELIMITER_ATT_NUMERIC_EXPRESSION:
- if (csgraph(c))
+ if (csgraph(c)
+ || (((c > 0) && (c < 012)) || (014 == c) || (0177 == c)))
is_valid = true;
// AT&T troff doesn't accept as numeric expression delimiters
// characters that validly appear in a numeric expression,
@@ -2799,7 +2801,8 @@ bool token::is_usable_as_delimiter(bool report_error,
&& (c != 'n')
&& (c != 'o')
&& (c != 't'))
- || cspunct(c))
+ || cspunct(c)
+ || (((c > 0) && (c < 012)) || (014 == c) || (0177 == c)))
is_valid = true;
// AT&T troff doesn't accept as conditional expression
// delimiters characters that can validly appear in a numeric
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit