groff-commit
[Top][All Lists]
Advanced

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

[groff] 05/05: tmac/s.tmac: Fix page number in table of contents.


From: G. Branden Robinson
Subject: [groff] 05/05: tmac/s.tmac: Fix page number in table of contents.
Date: Sun, 25 Oct 2020 06:55:16 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 08291b401786f57ffb8c8c3551455167bcfb4d31
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Oct 25 20:57:39 2020 +1100

    tmac/s.tmac: Fix page number in table of contents.
    
    Fix ms .TC macro by allowing it to actually use lowercase Roman numerals
    for the page(s) of the table of contents when a custom title (header or
    footer) is defined containing '%'.
    
    As a side effect, eliminate the PN register, which was apparently
    misused because it was undocumented and had a name just long enough to
    be both suggestive and ambiguous.  Another pin goes into my Ken Thompson
    voodoo doll.
    
    * tmac/s.tmac (IX): Write out page number of index term(s) in using the
      % register (instead of PN), obtaining whatever format is assigned to
      % the register at that time.
      (CH): Similarly, output %, not PN, in the center of the default
      heading.
      (PT): Save the format of %, set it to decimal, copy its value to a new
      register, pg*page-number-in-decimal, then restore %'s previous format.
      Compare the new register, not %, to 1 to determine whether special
      page one behavior should be used.
      (pg*end-page): Assign pg*next-format to %, not PN.
      (XA): Define toc*num with the interpolation of %, not PN.
    
    * tmac/tests/s-TC-works-with-percent-in-custom-titles.sh: Test.
    * tmac/tmac.an (tmac_TEST): Run test.
    
    Problem appears to be very old; as I read it, Larry Kollar was
    complaining of it in his ms.ms document over 20 years ago.
    
    Fixes <https://savannah.gnu.org/bugs/?59345>.
---
 ChangeLog   | 31 +++++++++++++++++++++++++++++++
 tmac/s.tmac | 16 ++++++++++------
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c3b22c3..9ce5d78 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,36 @@
 2020-10-25  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       Fix ms .TC macro by allowing it to actually use lowercase Roman
+       numerals for the page(s) of the table of contents when a custom
+       title (header or footer) is defined containing '%'.
+
+       As a side effect, eliminate the PN register, which was
+       apparently misused because it was undocumented and had a name
+       just long enough to be both suggestive and ambiguous.  Another
+       pin goes into my Ken Thompson voodoo doll.
+
+       * tmac/s.tmac (IX): Write out page number of index term(s) in
+       using the % register (instead of PN), obtaining whatever format
+       is assigned to the register at that time.
+       (CH): Similarly, output %, not PN, in the center of the default
+       heading.
+       (PT): Save the format of %, set it to decimal, copy its value to
+       a new register, pg*page-number-in-decimal, then restore %'s
+       previous format.  Compare the new register, not %, to 1 to
+       determine whether special page one behavior should be used.
+       (pg*end-page): Assign pg*next-format to %, not PN.
+       (XA): Define toc*num with the interpolation of %, not PN.
+
+       * tmac/tests/s-TC-works-with-percent-in-custom-titles.sh: Test.
+       * tmac/tmac.an (tmac_TEST): Run test.
+
+       Problem appears to be very old; as I read it, Larry Kollar was
+       complaining of it in his ms.ms document over 20 years ago.
+
+       Fixes <https://savannah.gnu.org/bugs/?59345>.
+
+2020-10-25  G. Branden Robinson <g.branden.robinson@gmail.com>
+
        * man/groff.7 (Requests/Request short reference) <.af>: Fix
        error; "l" is not a valid register format.  Explain what the
        request does, and the default format, as tersely as possible.
diff --git a/tmac/s.tmac b/tmac/s.tmac
index 39ad3ba..e045fa1 100644
--- a/tmac/s.tmac
+++ b/tmac/s.tmac
@@ -85,7 +85,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 ..
 .\" indexing
 .de IX
-.tm \\$1\t\\$2\t\\$3\t\\$4 ... \\n[PN]
+.tm \\$1\t\\$2\t\\$3\t\\$4 ... \\n[%]
 ..
 .\" print an error message and then try to recover
 .de @error-recover
@@ -454,7 +454,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .ds CF
 .ds RF
 .ds LH
-.ds CH -\En[PN]-
+.ds CH -\En[%]-\"
 .ds RH
 .ds pg*OH '\E*[LH]'\E*[CH]'\E*[RH]'
 .ds pg*EH '\E*[LH]'\E*[CH]'\E*[RH]'
@@ -467,7 +467,12 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .als OF OH
 .als EF OH
 .de PT
-.ie \\n%=1 .if \\n[pg*P1] .tl \\*[pg*OH]
+.\" To compare the page number to 1, we need it in decimal.
+.ds pg*saved-page-number-format \\g%\"
+.af % 0
+.nr pg*page-number-in-decimal \\n%
+.af % \\*[pg*saved-page-number-format]
+.ie \\n[pg*page-number-in-decimal]=1 .if \\n[pg*P1] .tl \\*[pg*OH]
 .el \{\
 .      ie o .tl \\*[pg*OH]
 .      el .tl \\*[pg*EH]
@@ -530,7 +535,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .\" top of page macro
 .de pg@top
 .ch pg*footer -\\n[FM]u/2u
-.nr PN \\n%
 .nr pg*col-num 0
 .nr pg@fn-bottom-margin 0
 .po \\n[PO]u
@@ -592,7 +596,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .              pn \\n[pg*next-number]
 .              rr pg*next-number
 .              if d pg*next-format \{\
-.                      af PN \\*[pg*next-format]
+.                      af % \\*[pg*next-format]
 .                      rm pg*next-format
 .              \}
 .      \}
@@ -1629,7 +1633,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .              ie '\\$1'no' .ds toc*num
 .              el .ds toc*num "\\$1
 .      \}
-.      el .ds toc*num \\n[PN]
+.      el .ds toc*num \\n[%]\"
 .      br
 .      par@reset
 .      na



reply via email to

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