groff-commit
[Top][All Lists]
Advanced

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

[groff] 09/30: [mm]: Validate `RP` macro arguments.


From: G. Branden Robinson
Subject: [groff] 09/30: [mm]: Validate `RP` macro arguments.
Date: Thu, 10 Oct 2024 20:18:11 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit eba88455ac8c947c333be9a90665970e7694789d
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Oct 9 08:27:44 2024 -0500

    [mm]: Validate `RP` macro arguments.
    
    * contrib/mm/m.tmac (RP): Validate macro arguments.
---
 contrib/mm/ChangeLog |  4 ++++
 contrib/mm/m.tmac    | 19 ++++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index 0b5d74194..c28c460b5 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,7 @@
+2024-10-09  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * m.tmac (RP): Validate macro arguments.
+
 2024-10-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * contrib/mm/m.tmac (initialization, LB, LI): Trivially
diff --git a/contrib/mm/m.tmac b/contrib/mm/m.tmac
index 1e4b32942..6aa315a48 100644
--- a/contrib/mm/m.tmac
+++ b/contrib/mm/m.tmac
@@ -3107,13 +3107,26 @@ exceeds depth of nested lists (\\n[li*lvl])
 .      @warning \\$0: ignoring; no references defined
 .      return
 .\}
-.ie !''\\$2' .nr ref*i 0\\$2
-.el          .nr ref*i \\n[Rpe]
+.\" Wart: mm treats the first argument as Boolean based on its
+.\" (non-)emptiness, not a numeric value.
+.nr ref*reset-counter 1
+.if !''\\$1' \{\
+.      ie \B'\\$1' .nr ref*reset-counter \\$1
+.      el          .@warning \\$0: treating non-numeric first \
+argument '\\$1' as '1'
+.\}
+.if \\n[ref*reset-counter] .nr ref*nr 0 1
+.nr ref*i \\n[Rpe]
+.if !''\\$2' \{\
+.      ie \B'\\$2' .nr ref*i \\$2
+.      el          .@warning \\$0: ignoring non-numeric second \
+argument: '\\$2'
+.\}
 .if \\n[ref*i]<2 .SK
 .SP 2
 .ref@print-refs
-.if 0\\$1<1 .nr ref*nr 0 1
 .if (\\n[ref*i]=0):(\\n[ref*i]=2) .SK
+.rr ref*reset-counter
 ..
 .\"-----------
 .\" called by end-of-text!



reply via email to

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