Update of bug #68137 (group groff):
Summary: [troff] issue warning in "syntax" category when
spaces used within numeric expressions in compatibility mode => [PACTH]
[troff] issue warning in "syntax" category when spaces used within numeric
expressions in compatibility mode
_______________________________________________________
Follow-up Comment #1:
commit 2bb521cdca9c15f7f0a5e34461227d9018972ebc (HEAD -> gbr-post-1.24)
Author: G. Branden Robinson <[email protected]>
Date: Tue Mar 10 07:21:48 2026 -0500
NEED CHANGELOG [troff]: Fix Savannah #68137.
* src/roff/troff/number.cpp (is_valid_expression): When interpreting a
parenthesized sub-expression within a numeric expression while in AT&T
compatibility mode, throw a warning in category "syntax" if
encountering a space in the input, advising of non-portability to that
family of formatters. GNU troff continues to interpret the expression
as it always has.
Illustration:
$ printf '.nr a (1 + 1)\n.tm \\na\n' | ~/groff-1.22.3/bin/groff
2
$ printf '.nr a (1 + 1)\n.tm \\na\n' | ./build/test-groff
2
$ printf '.nr a (1 + 1)\n.tm \\na\n' | ./build/test-groff -C
troff:<standard input>:1: warning: a space within a numeric expression is
not portable to AT&T troff
2
$ printf '.nr a (1 + 1)\n.tm \\na\n' | dwb troff >/dev/null
1
$ printf '.nr a (1 + 1)\n.tm \\na\n' | 9 troff >/dev/null
1
$ printf '.nr a (1 + 1)\n.tm \\na\n' | heirloom troff >/dev/null
2
(Heirloom Doctools troff defaults to a groff compatibility mode.
But maybe not for much longer:
https://github.com/n-t-roff/heirloom-doctools/issues/87#issuecomment-496761804
)
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index 5a5f4de59..1eef6b2dc 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -249,8 +249,14 @@ static bool is_valid_expression(units *u, int
scaling_unit,
int result = is_valid_term(u, scaling_unit, is_parenthesized,
is_mandatory);
while (result) {
- if (is_parenthesized)
- tok.skip_spaces();
+ if (is_parenthesized) {
+ if (want_att_compat && tok.is_space())
+ warning(WARN_SYNTAX, "%1 within a numeric expression"
+ " is not portable to AT&T troff", tok.description());
+ // See `token::skip_spaces()` in "input.cpp".
+ while (tok.is_space())
+ tok.next();
+ }
int op = tok.ch();// safely compares to char literals; TODO: grochar
switch (op) {
case int('+'): // TODO: grochar
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68137>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
