groff
[Top][All Lists]
Advanced

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

[Groff] an-old.tmac: without preceding RS, RE wrongly resets left margin


From: Ingo Schwarze
Subject: [Groff] an-old.tmac: without preceding RS, RE wrongly resets left margin
Date: Mon, 11 Nov 2013 08:42:54 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

Anthony J. Bentley wrote on Sun, Nov 10, 2013 at 01:34:54PM -0700:

> Consider this man(7) source, based on gpg.1:
> 
> .TP
> foo
> bar
> .RE  
> .PP
> baz

Actually, the point is that there is no preceding .RS.
A complete test case is:

.TH RS-LONELYRE 1 "November 10, 2013" OpenBSD
.SH NAME
RS-lonelyRE \- closing RS that is not open
.SH DESCRIPTION
.TP 6n
tag
body
.RE
out of body

> mandoc -Tlint complains (via man_macro.c:blk_close()):
> 
> ERROR: skipping end of block that is not open

groff(1) does not complain, which might be something else
that one could fix, but i'm keeping this patch minimal for now
to make review easier.

> and formats like so:
> 
>        foo    bar
> 
>        baz

OK, the man(7) code we have to process here is buggy,
RE without preceding RS is structurally invalid.
That said, i think what mandoc(1) does is the best
way to deal with this bad situation.

> Groff formats like so:
> 
>        foo    bar
> 
> baz

That seems like a bug.
Under no circumstances should the outer left margin be violated.
Only .SH headers should go that far left.

See below for a proposed fix to groff's tmac/an-old.tmac:
 - Whenever (re)setting \n[an-level] to 1 - which happens when
   encountering .TH, .SH, and .SS - make sure to also (re)set
   \n[an-saved-margin1] and \n[an-saved-prevailing-indent1]
   to a sane value such that immediate .RE cannot wreak havoc.
 - As .set-an-margin is always preceded by .nr an-level 1
   and followed by .nr an-prevailing-indent \\n[IN],
   and since these form a logical unit of action,
   pull the latter two into .de set-an-margin.

Comments and testing reports welcome.
I tested on the complete set of OpenBSD base system manuals
and found no regressions.  Rather, the formatting of the
nslookup(1) manual improves.

Yours,
  Ingo


Index: tmac/an-old.tmac
===================================================================
RCS file: /sources/groff/groff/tmac/an-old.tmac,v
retrieving revision 1.67
diff -u -r1.67 an-old.tmac
--- tmac/an-old.tmac    16 Jul 2013 07:20:48 -0000      1.67
+++ tmac/an-old.tmac    11 Nov 2013 07:34:39 -0000
@@ -122,7 +122,11 @@
 .\}
 .
 .de set-an-margin
+.  nr an-level 1
 .  nr an-margin \\n[IN]
+.  nr an-saved-margin1 \\n[IN]
+.  nr an-prevailing-indent \\n[IN]
+.  nr an-saved-prevailing-indent1 \\n[IN]
 ..
 .
 .ds an-extra1
@@ -198,9 +202,7 @@
 .  PD
 .  if !r SN \
 .    nr SN 3n \" the indentation of sub-sub-headings relative to sub-headings
-.  nr an-level 1
 .  set-an-margin
-.  nr an-prevailing-indent \\n[IN]
 .  nr an-tag-sep 1n
 .
 .  nr an-no-space-flag 0
@@ -342,9 +344,7 @@
 .
 .de1 SH
 .  sp \\n[PD]u
-.  nr an-level 1
 .  set-an-margin
-.  nr an-prevailing-indent \\n[IN]
 .  fi
 .  in \\n[an-margin]u
 .  ti 0
@@ -361,9 +361,7 @@
 .
 .de1 SS
 .  sp \\n[PD]u
-.  nr an-level 1
 .  set-an-margin
-.  nr an-prevailing-indent \\n[IN]
 .  fi
 .  in \\n[IN]u
 .  ti \\n[SN]u



reply via email to

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