bug-groff
[Top][All Lists]
Advanced

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

[bug #57538] [me] incorrect PostScript output of macro .(b


From: G. Branden Robinson
Subject: [bug #57538] [me] incorrect PostScript output of macro .(b
Date: Tue, 21 Dec 2021 20:21:06 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

Follow-up Comment #7, bug #57538 (project groff):

[comment #2 comment #2:]
> Because as it turns out, while the bug was in groff 1.21, and is in current
groff, it has not been in every version of groff released in between.  I'm not
sure which all official releases it appears in -- it is absent in at least
1.22.2 and 1.22.3 -- but I've iterated through the various versions of
tmac/e.tmac / tmac/e.tmac-u (the file was renamed at some point) to find out
exactly where it came and went.
> 
> The bug disappeared in commit b6906269 of this file and reappeared in commit
98b028d6.  But the interesting thing about this is that these commits also
respectively introduced and then removed another bug.
> 
> As documented, all "displays" in -me (of which ".(b" is one) should have
space corresponding to the \n(bs register above and below; the test case at
hand explicitly sets this register to 0, specifying no extra space above or
below the block.  But starting with commit b6906269, this test case began
emitting an extra line above the .(b block; commit 98b028d6 fixed this.
> 
> So somehow this extra-space bug removed, or at least masked, the page-break
bug as a side effect.

To make this history hyperlinked and concrete, here are Savannah Git repo
links for commit b6906269
<https://git.savannah.gnu.org/cgit/groff.git/commit/?id=b6906269>[1] and
commit 98b028d6
<https://git.savannah.gnu.org/cgit/groff.git/commit/?id=98b028d6>.

Here are the changes to e.tmac in each.


diff --git a/tmac/e.tmac b/tmac/e.tmac
index a5bfaabb5..af0a28e89 100644
--- a/tmac/e.tmac
+++ b/tmac/e.tmac
@@ -253,7 +253,7 @@
 .      sp |\\n(tmu             \" move to top of text
 .ev
 .mk _k                         \" for columned output
-.if \\n(?n .nm 1               \" restore line numbering if n1 mode
+.if \\n(?n=1 .nm 1             \" restore line numbering if n1 mode
 .nr $c 1                       \" set first column
 .if \n@>4 .tm -- @h >> .ns nl=\\n(nl %=\\n% _k=\\n(_k tm=\\n(tm
 .ie \\n(?s \
@@ -297,9 +297,13 @@
 .if \\n(?T \
 \{\
 .      nr _i \\n(.i
+.      if \\n(?n \
+.              nm \\n(ln
 .      in 0
 .      |h\"                    \" output the table header
 .      in \\n(_iu
+.      if \\n(?n \
+.              nm
 .      rr _i
 .      mk #T                   \" for tbl commands
 .      ns
@@ -351,7 +355,11 @@
 .in 0
 .if \n@>2 .tm @o last printed text = \\n(nl placing @r trap at -\\n(_B
 .wh -\\n(_Bu @r
+.if \\n(?n \
+.      nm \\n(ln
 .|f
+.if \\n(?n \
+.      nm
 .fi
 .if \n@>2 .tm @o triggered @r (?o) = \\n(?o
 .if \\n(?o \
@@ -394,9 +402,13 @@
 .      sz \\n(tp\"             \" set header/footer type fonts, etc.
 .      @F \\n(tf
 .      lt \\n(_Lu              \" make title span entire page
+.      if \\n(?n \
+.              nm \\n(ln
 .      nf
 .      \\$1
 .      br
+.      if \\n(?n \
+.              nm
 .\}
 ..
 .
@@ -506,16 +518,46 @@
 .
 .de n1                 \" *** line numbering 1
 .nm 1
-.xl -\w'0000'u
+.ll -\w'0000'u
 .nr ?n 1
 ..
 .
 .de n2                 \" *** line numbering 2
-.nm \\$1
 .ie \\n(.$ \
-.      xl -\w'0000'u
+\{\
+.      ie !`\\$2`c` \
+.              po -\w'0000'u
+.      el \
+.              ll -\w'0000'u
+.      ie \\B`\\$1` \
+\{\
+.              ds |i \\$1
+.              ds |j \\$1
+.              do substring |i 0 0  \" pick off leading char and rest to
check
+.              do substring |j 1    \" for +N / -N
+.              ie `\\*(|i`+` \
+.                      nr ln (\\n[_ln])+\\*(|j
+.              el \
+.                      ie `\\*(|i`-` \
+.                              nr ln (\\n[_ln])-\\*(|j
+.                      el \
+.                              nr ln \\$1  \" unsigned N
+.              nm \\n(ln
+.              nr ?n 2
+.              rm |i |j
+.\}
+.      el \
+.              tm Line \\n(.c -- Bad .n2 value
+.\}
 .el \
-.      xl \\n($lu
+\{\
+.      nm
+.      nr _ln \\n(ln
+.      po +\w'0000'u
+.      ll \\n($lu
+.      nr ?n 0
+.      nr ln 0
+.\}
 ..
 .
 .de pa                 \" *** new page
@@ -914,7 +956,11 @@
 .ls 1
 .in 0
 .sp \\n(zsu
+.if \\n(?n \
+.      nm \\n(ln
 .\\$1
+.if \\n(?n \
+.      nm
 .ec
 .br
 .rm \\$1
@@ -942,15 +988,8 @@
 .@)
 .if (\\n(bt=0):(\\n(.t<\\n(bt) \
 .      ne \\n(dnu              \" make it all on one page
-.ls 1
-.nf
-.|k
-.ec
-.fi
-.in 0
-.xl \\n($lu
-.ev
-.rm |k
+.@k |k
+.ev                             \" return from display environment
 .sp \\n(bsu+\\n(.Lv-1v
 ..
 .
@@ -992,6 +1031,7 @@
 .
 .de (c                 \" *** begin block centered text
 .if "\\n(.z"|c" .tm Line \\n(c. -- Nested .(c requests
+.if \\n(?n .nm
 .di |c
 ..
 .
@@ -1004,11 +1044,15 @@
 .ls 1
 .in (\\n(.lu-\\n(.iu-\\n(dlu)/2u
 .if \n@>4 .tm -- .)c << .in .l=\\n(.l .i=\\n(.i dl=\\n(dl
+.if \\n(?n \
+.      nm \\n(ln
 .nf
 .|c
 .ec
 .in
 .ls
+.if \\n(?n \
+.      nm
 .ev
 .rm |c
 ..
@@ -1025,10 +1069,14 @@
 .in +\\n(qiu
 .xl -\\n(qiu
 .sz \\n(qp
+.if \\n(?n \
+.      nm \\n(ln
 ..
 .
 .de )q                 \" *** end block quote
 .br
+.if \\n(?n \
+.      nm
 .ev
 .sp \\n(qsu+\\n(.Lv-1v
 .nr ?k 0
@@ -1039,11 +1087,15 @@
 .sp \\n(bsu
 .@D 3 \\$1 \\$2
 .@M
+.if \\n(?n \
+.      nm \\n(ln
 .if '\*(.T'html' .sp \\n(bsu
 ..
 .
 .de )l                 \" *** end list
 .br
+.if \\n(?n \
+.      nm
 .ev
 .sp \\n(bsu+\\n(.Lv-1v
 .nr ?k 0
@@ -1123,7 +1175,11 @@
 .      tl """\\*(|p"
 .      rt \\n(_qu
 .\}
+.if \\n(?n \
+.      nm \\n(ln
 .|e
+.if \\n(?n \
+.      nm
 .sp |\\n(_qu+\\n(_Qu
 .sp \\n(esu+\\n(.Lv-1v
 .rr _q
@@ -1157,12 +1213,14 @@
 .de TH                 \" *** end header part of table
 .nr T. 0
 .T# 0
+.if \\n(?n \!.nm
 .di
 .nr _T \\n(?T
 .nr ?T 0
 .ne \\n(dnu+1v
 .nr ?T \\n(_T
 .nr _i \\n(.i
+.if \\n(?n .nm \\n(ln
 .in 0
 .|h\"                          \" put in the initial header
 .in \\n(_iu
@@ -1220,9 +1278,41 @@
 .ne \\$1u
 .nr g7 \\n(.u
 .ls 1
+.if \\n(?n \
+\{\
+.      de PS_nm_check &&        \" define macro to emit .nm at top diversion
+.      if \n@>4 .tm -- PS: \\\\$1 \\\\$2 .z=\\\\n(.z
PS_nm_cnt=\\\\n[PS_nm_cnt]
+.      \"                       \" multiple .PS/.PE in a keep.
+.      if `\\\\$2`init` \
+.              do nr PS_nm_cnt \\\\n[PS_nm_cnt]+1
+.      ie `\\\\n(.z`` \
+\{\
+.              if `\\\\$1`suspend` \
+.                      nm
+.              if `\\\\$1`resume` \
+\{\
+.                      nm \\\\n(ln
+.                      do nr PS_nm_cnt \\\\n[PS_nm_cnt]-1
+.                      do if !\\\\n[PS_nm_cnt] \
+\{\
+.                              do rm PS_nm_check
+.                              do rr PS_nm_cnt
+.\}
+.\}
+.\}
+.el \!.PS_nm_check \\\\$1
+.&&
+.      mk _q                    \" emit a single numbered line for PS
picture
+.      rs
+\&\ 
+.      br
+.      rt \\n(_qu
+.      PS_nm_check suspend init
+.\}
 ..
 .
 .de PE                 \" *** end picture
+.if \\n(?n .PS_nm_check resume
 .ls
 .in
 .if \\n(g7 .fi
@@ -1380,6 +1470,7 @@
 .      nr _D \\n(dn
 .      nr _0 1v+\\n(nlu
 .      ev 2
+.      nm
 .      da |f
 .      in 0
 .      xl \\n($lu-\\n(fuu
@@ -1420,6 +1511,7 @@
 .el \
 \{\
 .      ev 2
+.      nm
 .      in 0
 .      xl \\n($lu-\\n(fuu
 .      @F \\n(ff


(A bit less atomic than one might hope.)


diff --git a/tmac/e.tmac-u b/tmac/e.tmac-u
index 778e3adb1..3c380c87f 100644
--- a/tmac/e.tmac-u
+++ b/tmac/e.tmac-u
@@ -986,7 +986,7 @@
 .nf
 .ls 1
 .in 0
-.sp \\n(zsu
+.if !`\\$2`ns` .sp \\n(zsu     \" no pre-spacing if (b .. )b
 .if \\n(?n \
 .      nm \\n(ln
 .\\$1
@@ -1019,7 +1019,7 @@
 .@)
 .if (\\n(bt=0):(\\n(.t<\\n(bt) \
 .      ne \\n(dnu              \" make it all on one page
-.@k |k
+.@k |k ns
 .ev                             \" return from display environment
 .sp \\n(bsu+\\n(.Lv-1v
 ..


[1] This is the notorious George Helffrich "bane of my existence" commit.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?57538>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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