gbranden pushed a commit to branch master
in repository groff.

commit 33ca41f500f78ff8afaa408d7d95fb0a2f0d2b32
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Oct 9 14:16:00 2025 -0500

    [tbl]: Fix Savannah #64529.
    
    * tmac/s.tmac: Manage keeps and initialize package more robustly.
    
      (TS): If the first macro call seen in a document is `TS`, call
      `cov*ab-init` directly instead of going through `LP`, which
      automatically closes an open diversion.
    
      (KE): Track whether we closed in a diversion in new module register
      `kp*did-closure-succed*, initializing its Boolean value to zero.
      After existing logic calling appropriate closure macros, test the
      register again, and issue a diagnostic only if it is not true.
    
      (kp*end, kp*fend): Set `kp*did-closure-succed`.
    
    Fixes <https://savannah.gnu.org/bugs/?64529>.  Thanks to Doug McIlroy
    for the report (way back in 2011!).  Problem is at least that old.
---
 ChangeLog   | 20 ++++++++++++++++++++
 tmac/s.tmac | 14 ++++++++------
 2 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 12f53e2a9..7defdf414 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2025-10-09  G. Branden Robinson <[email protected]>
+
+       [tbl]: Fix Savannah #64529.
+
+       * tmac/s.tmac: Manage keeps and initialize package more
+       robustly.
+       (TS): If the first macro call seen in a document is `TS`, call
+       `cov*ab-init` directly instead of going through `LP`, which
+       automatically closes an open diversion.
+       (KE): Track whether we closed in a diversion in new module
+       register `kp*did-closure-succed*, initializing its Boolean value
+       to zero.  After existing logic calling appropriate closure
+       macros, test the register again, and issue a diagnostic only if
+       it is not true.
+       (kp*end, kp*fend): Set `kp*did-closure-succed`.
+
+       Fixes <https://savannah.gnu.org/bugs/?64529>.  Thanks to Doug
+       McIlroy for the report (way back in 2011!).  Problem is at least
+       that old.
+
 2025-10-09  G. Branden Robinson <[email protected]>
 
        [ms]: Regression-test Savannah #64529.
diff --git a/tmac/s.tmac b/tmac/s.tmac
index 46ac2b831..f91822958 100644
--- a/tmac/s.tmac
+++ b/tmac/s.tmac
@@ -934,11 +934,11 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .par@reset
 ..
 .de KE
-.ie '\\n(.z'kp@div' .kp*end
-.el \{\
-.      ie '\\n(.z'kp@fdiv' .kp*fend
-.      el .@error .KE without .KS or .KF
-.\}
+.nr kp*did-closure-succeed 0
+.if '\\n(.z'kp@div'  .kp*end
+.if '\\n(.z'kp@fdiv' .kp*fend
+.if !\\n[kp*did-closure-succeed] .@error .KE without .KS or .KF
+.rr kp*did-closure-succeed
 ..
 .de @div-end!kp@div
 .kp*end
@@ -959,6 +959,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .kp@div
 .ev
 .rm kp@div
+.nr kp*did-closure-succeed 1
 ..
 .\" Floating keeps.
 .nr kp@head 0
@@ -980,6 +981,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .      nr kp*ht!\\n[kp@tail] 0\\n[dn]
 .      nr kp@tail +1
 .\}
+.nr kp*did-closure-succeed 1
 ..
 .\" top of page processing for KF
 .nr kp*doing-top 0
@@ -2007,7 +2009,7 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>.
 .nr tbl*has-heading 0
 .\" This gets called if TS occurs before the first paragraph.
 .de TS
-.LP
+.cov*ab-init
 .\" cov*ab-init, called by LP, aliases TS to @TS.
 \\*[TS]\\
 ..

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to