groff-commit
[Top][All Lists]
Advanced

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

[groff] 17/21: [man]: Restore robustness to `EE` misuse.


From: G. Branden Robinson
Subject: [groff] 17/21: [man]: Restore robustness to `EE` misuse.
Date: Tue, 23 Aug 2022 14:18:43 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit f287bb7243a7d77e8b4f3a432d00c6f0681b687d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Aug 23 12:56:02 2022 -0500

    [man]: Restore robustness to `EE` misuse.
    
    * tmac/an.tmac: Add `an*is-in-example` register to keep track state of
      within-exampleness.  Not doing so can cause a spurious use of `EE` to
      wrongly set the inter-paragraph distance to zero.
    
      (TH): Initialize register.
    
      (EX): Test register; if set, ignore macro call and, if `CHECKSTYLE`
      warnings are on, throw diagnostic.  Set register.
    
      (EE): Test register; if clear, ignore macro call and, if `CHECKSTYLE`
      warnings are on, throw diagnostic.  Clear register.
    
    * tmac/an-ext.tmac (EX, EE): Similar, using `mX` register.  Because AT&T
      troff had no `return` request, invert the sense of the tests and put
      the entire macro bodies inside conditionals.
    
    This regressed post-1.22.4.  Thanks to Ingo Schwarze for the report and
    a proposed patch.
---
 ChangeLog        | 20 ++++++++++++++++++++
 tmac/an-ext.tmac | 22 ++++++++++++++--------
 tmac/an.tmac     | 11 +++++++++++
 3 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 94637fbc6..a8b21d151 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2022-08-23  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [man]: Restore robustness to `EE` misuse.
+
+       * tmac/an.tmac: Add `an*is-in-example` register to keep track
+       state of within-exampleness.  Not doing so can cause a spurious
+       use of `EE` to wrongly set the inter-paragraph distance to zero.
+       (TH): Initialize register.
+       (EX): Test register; if set, ignore macro call and, if
+       `CHECKSTYLE` warnings are on, throw diagnostic.  Set register.
+       (EE): Test register; if clear, ignore macro call and, if
+       `CHECKSTYLE` warnings are on, throw diagnostic.  Clear register.
+
+       * tmac/an-ext.tmac (EX, EE): Similar, using `mX` register.
+       Because AT&T troff had no `return` request, invert the sense of
+       the tests and put the entire macro bodies inside conditionals.
+
+       This regressed post-1.22.4.  Thanks to Ingo Schwarze for the
+       report and a proposed patch.
+
 2022-08-23  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * tmac/an-ext.tmac: Refactor.  Rename `mX` to `mZ` so we can use
diff --git a/tmac/an-ext.tmac b/tmac/an-ext.tmac
index 20128f4d9..8f949e387 100644
--- a/tmac/an-ext.tmac
+++ b/tmac/an-ext.tmac
@@ -247,20 +247,26 @@
 .\" Start example.
 .if \n(.g .ig
 .de EX
-.  nr mF \\n(.f
-.  nr mP \\n(PD
-.  nr PD 1v
-.  nf
-.  ft \\*(mC
+.  if !\\n(mX \{\
+.    nr mF \\n(.f
+.    nr mP \\n(PD
+.    nr PD 1v
+.    nf
+.    ft \\*(mC
+.    nr mX 1
+.  \}
 ..
 .
 .
 .\" End example.
 .if \n(.g .ig
 .de EE
-.  ft \\n(mF
-.  nr PD \\n(mP
-.  fi
+.  if \\n(mX \{\
+.    ft \\n(mF
+.    nr PD \\n(mP
+.    fi
+.    nr mX 0
+.  \}
 ..
 .
 .
diff --git a/tmac/an.tmac b/tmac/an.tmac
index cf28fc3ce..88b25163f 100644
--- a/tmac/an.tmac
+++ b/tmac/an.tmac
@@ -267,6 +267,7 @@
 .  nr an-need-no-space-mode 0
 .  nr an-need-break 0
 .  nr an-is-in-diversion 0
+.  nr an*is-in-example 0
 .
 .  ds an-title "\\$1\"
 .  if \\n[CT] .stringup an-title
@@ -986,6 +987,10 @@ contains unsupported escape sequence
 .
 .\" Begin an example (typically of source code or shell input).
 .de1 EX
+.  if \\n[an*is-in-example] \{\
+.    an-style-warn ignoring .\\$0 while already in example
+.    return
+.  \}
 .  ds an*saved-family \\n[.fam]
 .  nr an*saved-font \\n[.f]
 .  nr an*saved-paragraph-distance \\n[PD]
@@ -1002,10 +1007,15 @@ contains unsupported escape sequence
 .  \}
 .  el .fam \\*[an*example-family]
 .  ft R
+.  nr an*is-in-example 1
 ..
 .
 .\" End example.
 .de EE
+.  if !\\n[an*is-in-example] \{\
+.    an-style-warn ignoring .\\$0 while not in example
+.    return
+.  \}
 .  \" Undo the remappings from `EX`.
 .  ie '\*[.T]'dvi' \{\
 .    ftr R
@@ -1020,6 +1030,7 @@ contains unsupported escape sequence
 .  rr an*saved-paragraph-distance
 .  rr an*saved-font
 .  rm an*saved-family
+.  nr an*is-in-example 0
 ..
 .
 .\" Set a man page cross reference.



reply via email to

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