groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: groff now undoing .ad settings after .IP


From: G. Branden Robinson
Subject: Re: groff now undoing .ad settings after .IP
Date: Fri, 15 Mar 2024 13:53:40 -0500

At 2024-03-15T10:57:03-0700, Russ Allbery wrote:
> Dave Kemper <saint.snit@gmail.com> writes:
> > It doesn't affect the larger point of this email, but the specific .ad
> > call Russ cites (in an-write-paragraph-tag) appears to have been added
> > in response to http://savannah.gnu.org/bugs/?62051 .
> 
> Right, the invocation in .TH was already handled because groff is not
> the first an macro implementation to set the adjustment in the body of
> the .TH macro, so pod2man puts the ".if n .ad l" line after the .TH
> invocation.  It was the change to the implementation of .TP/.IP that
> caused the user-visible behavior change.

Ahh, hmm.  Yes, Dave's got a point.  I may have been so bowled over at
my command of *roff history not being what I thought it was that I
mis-scoped the problem you reported and, potentially, its solution.

The fix for Savannah #62051 was a two-liner:

diff --git a/tmac/an.tmac b/tmac/an.tmac
index 59a7156b1..a568d69cd 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -554,6 +554,7 @@ .de1 an-footer
 .de an-write-paragraph-tag
 .  br
 .  di
+.  ad \\*[AD]
 .  nr an-is-in-diversion 0
 .  ll
 .  \" We must emit the diversion in a separate environment to ensure
@@ -707,6 +708,7 @@ .de1 TP
 .  if !\\n[an-is-in-diversion] \{\
 .    ll -\\n[an-margin]u
 .    di an-div
+.    na
 .  \}
 .  nr an-is-in-diversion 1
 ..

Can you name me a misbehaving perlpod(1)-generated page?  I'll check it
out.  Perhaps what I really needed here was:

--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -554,6 +554,7 @@ .de1 an-footer
 .de an-write-paragraph-tag
 .  br
 .  di
+.  ad \\n[an*saved-adjustment-mode]
+.  rr an*saved-adjustment-mode
 .  nr an-is-in-diversion 0
 .  ll
 .  \" We must emit the diversion in a separate environment to ensure
@@ -707,6 +708,7 @@ .de1 TP
 .  if !\\n[an-is-in-diversion] \{\
 .    ll -\\n[an-margin]u
 .    di an-div
+.    nr an*saved-adjustment-mode \\n[.j]
+.    na
 .  \}
 .  nr an-is-in-diversion 1
 ..

I want to do some testing because we have another scenario coming up in
groff 1.24.

.\" The TP macro _requires_ a one-line input trap.
.de1 an*TP-trap
.  br
.  di
.  ad \\*[AD]
.  ll
.  if \\n[an*have-paragraph-tag] .an-write-paragraph-tag
..

I see additional regression tests in my future.  We're closing in on 200
automated test scripts.

> It's been enough years that I don't recall what other implementation
> set adjustment in the .TH macro body, although I do remember
> originally setting adjustment in the preamble and having to move it
> until after the .TH invocation for it to be effective.  Given what
> systems I was doing development on the time, it's possible it was
> Solaris of the 2.6 or 7 vintage.

A long time for sure.  In Solaris _10_ troff's tmac.an, which has a
GitHub repo,[1] `TH` has a relict ".if n .na"--that is, it's commented
out.  But for how long it had been commented out, I have no idea.  And
sure enough, SSHing to a Solaris 10 box and "man ls" tells me that
adjustment to both margins is on.

[Continues poking around, in non-publicly available sources...]

Ah.  Same commented out request in the same tmac.an macro in...

Drum roll, please...

SunOS 4 (1988).

Same thing in SunOS 3.5, SunOS 3.2, and SunOS 2.0 (1982!).

So as with many decisions James Clark made with groff, he was aiming at
straight-down-the-line Sun compatibility.  Mystery solved.

Regards,
Branden

[1] https://github.com/n-t-roff/Solaris10-ditroff

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]