Hi,
onf wrote on Sat, Oct 18, 2025 at 03:05:55AM +0200:
> including .T as an argument to an mdoc macro causes its contents
> to be interpolated.
I can confirm this, let me say this more precisely:
In groff-1.23, if one of the arguments to a groff_mdoc(7) macro
is exactly ".T", that argument is apparently treated as if it
were "\*(.T", and that seems like a bug in groff to me.
mandoc is unaffected by this bug, and i can't easily test with
groff-current right now.
> Example to reproduce:
> .Dd October 18, 2025
> .Dt EXAMPLE 1
> .Os
> .Sh DESCRIPTION
> .No Device name is stored in the string .T .
>
> It is not limited to No, though; the following more realistic
> input also causes .T to be interpolated:
[using the corrected input from the second mail]
> .Bl -column "device name"
> .It Name Ta Meaning
> .It device name Ta Dv .T
> .El
See below for a comparison of groff and mandoc output with the above input.
Also note the bogus warning printed by groff:
mdoc warning: Using a macro as first argument cancels effect of .Dv (#8)
The roff(7) language does not predefine many strings as far as i'm aware,
so i also tested with one of the strings predefined by manual page
macro sets: \*(Ba prints a vertical bar as expected, but a macro
argument "Ba" prints simply "Ba" rather than a vertical bar.
So the bug seems unique to .T.
> Is this correct behavior?
I don't think it is.
> My assumption until now was that
> only callable mandoc macros are supposed to be interpolated.
Indeed, no string interpolation is supposed to occur when the \*
escape sequence is not used.
> Furthermore, mandoc does not exhibit this behavior (or warn
> about the unescaped .T when run with -T lint).
Confirmed, and i see no reason why mandoc(1) should warn about
a macro argument that is exactly ".T". That looks like a totally
ordinary macro argument to me and should have nothing whatsoever
to do with user-defined or pre-defined strings.
Yours,
Ingo
$ gmdiff tmp.mdoc
========== tmp.mdoc ==========
roff errors:
mdoc warning: Using a macro as first argument cancels effect of .Dv (#8)
mandoc errors:
mandoc: tmp.mdoc:1:5: STYLE: Mdocdate missing: Dd October 18, 2025 (OpenBSD)
mandoc: tmp.mdoc:4:2: WARNING: first section is not "NAME": Sh DESCRIPTION
mandoc: tmp.mdoc: STYLE: RCS id missing: (OpenBSD)
mandoc: see above the output for WARNING messages
--- /tmp/roff.out Tue Oct 28 19:44:02 2025
+++ /tmp/mandoc.out Tue Oct 28 19:44:02 2025
@@ -1,9 +1,9 @@
EXAMPLE(1) General Commands Manual EXAMPLE(1)
DESCRIPTION
- Device name is stored in the string ascii.
+ Device name is stored in the string .T.
Name Meaning
- device name ascii.
+ device name .T
OpenBSD October 18, 2025 EXAMPLE(1)