groff-commit
[Top][All Lists]
Advanced

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

[groff] 22/33: [mm]: Fix Savannah #54909.


From: G. Branden Robinson
Subject: [groff] 22/33: [mm]: Fix Savannah #54909.
Date: Sun, 29 Jan 2023 19:35:30 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit 814e204d1675ef9c6da4fb4e2736d5937256f106
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Jan 24 14:47:24 2023 -0600

    [mm]: Fix Savannah #54909.
    
    When register `Pt` was 2, paragraphs immediately following displays and
    lists were being indented, contrary to DWB mm behavior.
    
    * m.tmac: Replace `par@ind-flag` register with two separate state bits,
      `par*indentation-eligible` and `par@suppress-indentation`.
    
      (P, nP): Remove complex test for deciding whether the current
      paragraph is being set immediately after a heading.
    
      (P): Set `par*indentation-eligible` to the logical complement of
      `par@suppress-indentation`.  Call `par@doit` (which underlies both `P`
      and `nP`) unconditionally.
    
      (nP): Force `par*indentation-eligible` off, since numbered paragraphs
      are not influenced by a `Pt` value of "2" in DWB mm.  {The paragraph
      number occupies the indentation space.} (par@doit): Introduce local
      register `par*do-indent`, manipulate it, and use it to control `ti`
      request instead of scattering the request across multiple locations.
      Remove this register when done.  Clear `par@suppress-indentation` at
      end, since after indentation is suppressed once, it should not happen
      again until a special circumstance (the setting of a heading, display,
      or list) arises.
    
      (H): Convert test of `hd*htype` register, which tells us if we're
      setting a run-in heading or not, from `if` to `ie`.  (The first
      paragraphing macro call after a run-in heading should _not_ have its
      indentation suppressed, because the material after the heading title
      constitutes a first pagraph.)  In the true arm, set
      `par@suppress-indentation`; in the new else arm, clear it.  This
      replaces the "complex test" above, and seems much more straightforward
      and reliable.  Stop manipulating `par@ind-flag`.
    
      (df@end, ds@end, LC): Set `par@suppress-indentation` instead of
      clearing `par@ind-flag`.
    
      (LE): Set `par@suppress-indentation`.
    
    Fixes Savannah #54909.  Thanks to Jeff Conrad for the report.
---
 contrib/mm/ChangeLog | 39 +++++++++++++++++++++++++++++++++++++++
 contrib/mm/m.tmac    | 48 ++++++++++++++++++++++++------------------------
 2 files changed, 63 insertions(+), 24 deletions(-)

diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index 89525546f..b5ba8c0ef 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,42 @@
+2023-01-24  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       When register `Pt` was 2, paragraphs immediately following
+       displays and lists were being indented, contrary to DWB mm
+       behavior.
+
+       * m.tmac: Replace `par@ind-flag` register with two separate
+       state bits, `par*indentation-eligible` and
+       `par@suppress-indentation`.
+       (P, nP): Remove complex test for deciding whether the current
+       paragraph is being set immediately after a heading.
+       (P): Set `par*indentation-eligible` to the logical complement of
+       `par@suppress-indentation`.  Call `par@doit` (which underlies
+       both `P` and `nP`) unconditionally.
+       (nP): Force `par*indentation-eligible` off, since numbered
+       paragraphs are not influenced by a `Pt` value of "2" in DWB mm.
+       {The paragraph number occupies the indentation space.}
+       (par@doit): Introduce local register `par*do-indent`,
+       manipulate it, and use it to control `ti` request instead of
+       scattering the request across multiple locations.  Remove this
+       register when done.  Clear `par@suppress-indentation` at end,
+       since after indentation is suppressed once, it should not happen
+       again until a special circumstance (the setting of a heading,
+       display, or list) arises.
+       (H): Convert test of `hd*htype` register, which tells us if
+       we're setting a run-in heading or not, from `if` to `ie`.  (The
+       first paragraphing macro call after a run-in heading should
+       _not_ have its indentation suppressed, because the material
+       after the heading title constitutes a first pagraph.)  In the
+       true arm, set `par@suppress-indentation`; in the new else arm,
+       clear it.  This replaces the "complex test" above, and seems
+       much more straightforward and reliable.  Stop manipulating
+       `par@ind-flag`.
+       (df@end, ds@end, LC): Set `par@suppress-indentation` instead of
+       clearing `par@ind-flag`.
+       (LE): Set `par@suppress-indentation`.
+
+       Fixes #54909.  Thanks to Jeff Conrad for the report.
+
 2023-01-24  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        Regression-test Savannah #54909.
diff --git a/contrib/mm/m.tmac b/contrib/mm/m.tmac
index 42eaf349c..0a5ab82b0 100644
--- a/contrib/mm/m.tmac
+++ b/contrib/mm/m.tmac
@@ -437,7 +437,8 @@ in=\\n[.i] fi=\\n[.u] .d=\\n[.d] nl=\\n[nl] pg=\\n[%]
  .p=\\n[.p] .t=\\n[.t] .z=\\n[.z] nl=\\n[nl] dn=\\n[dn] n=\\n[debug*n]
 ..
 .\" ####### module par #################################
-.nr par@ind-flag 1     \" indent on following P if Pt=2
+.nr par*indentation-eligible 1         \" indent following P if Pt=2
+.nr par@suppress-indentation 0
 .nr hd*last-pos -1
 .nr hd*last-hsize -1
 .nr par*number 0 1
@@ -468,39 +469,36 @@ in=\\n[.i] fi=\\n[.u] .d=\\n[.d] nl=\\n[nl] pg=\\n[%]
 .      tm Paragraph nl=\\n[nl], last=\\n[hd*last-pos]
 .      tm Paragraph .k=\\n[.k], hsize=\\n[hd*last-hsize]
 .\}
-.if !((\\n[nl]=\\n[hd*last-pos])&(\\n[hd*last-hsize]=\\n[.k])) \{\
-.      if \\n[D]>2 .tm Paragraph set ind-flag=1
-.      nr par@ind-flag 1
-.      \" any collected unprinted text?
-.      par@doit \\$*
-.\}
+.nr par*indentation-eligible 1-\\n[par@suppress-indentation]
+.par@doit \\$*
 .if \\n[Np] \\n[H1].\\n+[par*number]\ \ \c
 ..
 .\"------------
 .de nP
-.\"    skip P if previous heading
 .if \\n[D]>2 \{\
 .      tm Paragraph nl=\\n[nl], last=\\n[hd*last-pos]
 .      tm Paragraph .k=\\n[.k], hsize=\\n[hd*last-hsize]
 .\}
-.if !((\\n[nl]=\\n[hd*last-pos])&(\\n[hd*last-hsize]=\\n[.k])) \{\
-.      if \\n[D]>2 .tm Paragraph set ind-flag=1
-.      nr par@ind-flag 1
-.\}
-.par@doit \\$*
+.\" A first-line indentation is meaningless for a numbered paragraph.
+.nr par*indentation-eligible 0
+.par@doit
 \\n[H2].\\n+[par*number2]\ \ \c
-.nr par@ind-flag 1
 ..
 .\"------------
 .de par@doit
 .SP (u;\\n[Ps]*\\n[Lsp])
-.ie  \\n[.$] \{\
-.      if \\$1=1 .ti +\\n[Pi]n
+.nr par*do-indent 0
+.ie \\n[.$] \{\
+.      if \\$1=1 .nr par*do-indent 1
 .\}
 .el \{\
-.      if \\n[Pt]=1 .ti +\\n[Pi]n
-.      if (\\n[Pt]=2)&\\n[par@ind-flag] .ti +\\n[Pi]n
+.      if \\n[Pt]=1 .nr par*do-indent 1
+.      if (\\n[Pt]=2)&\\n[par*indentation-eligible] \
+.              nr par*do-indent 1
 .\}
+.if \\n[par*do-indent] .ti +\\n[Pi]n
+.rr par*do-indent
+.nr par@suppress-indentation 0
 ..
 .\" ####### module line #######################################
 .de SP
@@ -1177,13 +1175,15 @@ numeric; got '\\$1'
 .\"    do break or space
 .if \\n[hd*htype] .br
 .if \\n[hd*htype]>1 .SP (u;\\n[Lsp]*\\n[Hss])
-.if \\n[hd*htype] \{\
+.ie \\n[hd*htype] \{\
 .      \"      indent if Hi=1 and Pt=1
 .      if (\\n[Hi]=1)&(\\n[Pt]=1) .ti +\\n[Pi]n
 .      \"      indent size of mark if Hi=2
 .      if \\n[hd*htype]&(\\n[Hi]>1) .ti +\\n[hd*mark-size]u
+.      nr par@suppress-indentation 1
 .\}
-.nr par@ind-flag 0                     \" no indent on .P if Pt=2
+.\" We're setting a run-in heading; the next paragraph is normal.
+.el .nr par@suppress-indentation 0
 .\"
 .\"    check if it is time to reset footnotes
 .if (\\n[hd*level]=1)&\\n[ft*clear-at-header] .nr ft*nr 0 1
@@ -1199,7 +1199,6 @@ numeric; got '\\$1'
 .if d HZ .HZ \\n[hd*level] \\n[hd*arg1] "\\$2\\$3"
 .nr hd*last-pos \\n[nl]
 .nr hd*last-hsize \\n[.k]
-.nr par@ind-flag 0
 .\" HTML: end of heading
 .misc@tag EO-H
 ..
@@ -1978,7 +1977,7 @@ within DF/DE
 .\"    move div to the floating display list
 .rn df*div df*fdiv!\\n[df*fnr]
 .\"
-.nr par@ind-flag 0
+.nr par@suppress-indentation 1 \" no indentation after displays
 .\" print float if queue is empty and the display fits into
 .\" the current page
 .if ((\\n[df*fnr]>=\\n[df*o-fnr])&(\\n[dn]<\\n[.t])) .df@print-float 1
@@ -2256,7 +2255,7 @@ within DF/DE
 .if \\n[ds*format]=4 'rj 0
 .rm ds*div!\\n[ds*snr]
 .nr ds*snr -1
-.nr par@ind-flag 0
+.nr par@suppress-indentation 1 \" no indentation after displays
 .ev
 ..
 .\"########### module list ###################
@@ -2356,6 +2355,7 @@ first
 and LI first
 .li@pop
 .if '\\$1'1' .SP \\n[Lsp]u
+.nr par@suppress-indentation 1 \" no indentation after lists
 ..
 .\"-------------
 .\"    list status clear.
@@ -2369,7 +2369,7 @@ and LI first
 .if \\n[li*i]>\\n[li*lvl] .@error \\$0 invalid argument: \\n[li*i] \
 exceeds depth of nested lists (\\n[li*lvl])
 .while \\n[li*lvl]>\\n[li*i] .li@pop
-.nr par@ind-flag 0
+.nr par@suppress-indentation 1 \" no indentation after lists
 ..
 .\"-------------
 .de AL



reply via email to

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