[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix right margin in an-old.tmac after double .TP
From: |
Ingo Schwarze |
Subject: |
Fix right margin in an-old.tmac after double .TP |
Date: |
Mon, 24 Jun 2013 13:35:23 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
GROFF VERSION: groff-1.22.2p0 (OpenBSD-current port)
MACHINE: IBM ThinkPad Z61m (OpenBSD.i386)
OS: OpenBSD-current (post-5.3)
COMPILER: g++ (GCC) 4.2.1 20070719 with standard OpenBSD patches
INPUT FILES:
Here is a contrived example file:
.TH TP-DOUBLE 1 2013-06-23 OpenBSD
.SH NAME
TP-double \- effect of double tagged paragraph
.SH DESCRIPTION
leading text:
This is a rather long text because we want to test the text width;
at which point will this text wrap to the next line?
.TP 16n
.TP 16n
double TP
This is a rather long text because we want to test the text width;
at which point will this text wrap to the next line?
.PP
normal paragraph:
This is a rather long text because we want to test the text width;
at which point will this text wrap to the next line?
The problem was originally found in the real-world unzip(1) manual,
see http://www.info-zip.org/UnZip.html
and ftp://ftp.info-zip.org/pub/infozip/src/unzip60.tgz
COMMAND LINE:
nroff -man -c double.man
(with the groff_man(7) macros bundled in groff-1.22.2)
DESCRIPTION OF INCORRECT BEHAVIOUR:
When two .TP macros start on adjacent lines, the right margin wrongly
moves left by the indentation of the first TP; it will never be reset
to the original value.
Correct behaviour would be for the right margin to always stay as it is.
The reason is that the roff(7) .ll request (line length) is used
at exactly three relevant places in an-old.tmac:
- At the end of ".de1 TH" for the initial setup
of the manual page as a whole.
- In ".de1 TP" to set up the reduced line length
for the TP diversion.
- In ".de an-do-tag" to restore the previous line length
after the TP diversion.
- (.TS/.TE/.EQ/.EN are irrelevant here.)
What happens is that the first .TP reduces the line length, moving the
original line length to the save location, the second .TP is called
before .an-do-tag, so the second .TP reduces the line length *again*,
moving the already reduced line length to the save location, so the
original line length cannot be restored any longer, and the line length
stays reduced for good.
There are two ways to fix this:
a) Change the line ".ll" in ".de1 an-do-tag" to read ".ll \\n[LL]u",
such that it doesn't rely on the saved line length.
The downside is that this would break code like the following:
.ll 42n \" or whatever the user wants
some text
.TP 8n
tag
some other text
.PP
yet some other text
.ll \\n[LL]u
final text
In this example, the user probably wants "yet some other text"
set with 42n line length. But with the way a) to fix the
problem, at the end of the .TP, the line length would be reset
to the full line length, setting "yet some other text" to full
width.
b) Instead, i'm proposing the following patch.
It only reduces the line length for the *first* of a group
of adjacent .TP macro lines. Consequently, the original
line length will not be lost.
SUGGESTED FIX:
Index: ChangeLog
===================================================================
RCS file: /sources/groff/groff/ChangeLog,v
retrieving revision 1.1426
diff -u -p -r1.1426 ChangeLog
--- ChangeLog 10 Jun 2013 13:39:30 -0000 1.1426
+++ ChangeLog 24 Jun 2013 11:18:37 -0000
@@ -1,3 +1,7 @@
+2013-06-24 Ingo Schwarze <address@hidden>
+
+ * tmac/an-old.tmac: do not clobber line length after double .TP
+
2013-06-19 Eric S. Raymond <address@hidden>
* src/utils/lkbib/lbib.man: Move running text out of synopsis.
Index: tmac/an-old.tmac
===================================================================
RCS file: /sources/groff/groff/tmac/an-old.tmac,v
retrieving revision 1.66
diff -u -p -r1.66 an-old.tmac
--- tmac/an-old.tmac 1 Mar 2012 05:05:48 -0000 1.66
+++ tmac/an-old.tmac 24 Jun 2013 11:18:42 -0000
@@ -406,8 +406,10 @@
. if \\n[.$] .nr an-prevailing-indent (n;\\$1)
. it 1 an-trap
. in 0
-. ll -\\n[an-margin]u
-. if !\\n[an-div?] .di an-div
+. if !\\n[an-div?] \{\
+. ll -\\n[an-margin]u
+. di an-div
+. \}
. nr an-div? 1
..
.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Fix right margin in an-old.tmac after double .TP,
Ingo Schwarze <=