groff-commit
[Top][All Lists]
Advanced

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

[groff] 19/25: [mm]: Improve `VERBON` argument validation.


From: G. Branden Robinson
Subject: [groff] 19/25: [mm]: Improve `VERBON` argument validation.
Date: Tue, 29 Oct 2024 02:26:06 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 0c9df885bfdb7cfb9b35e4348d8227f4bdc7aa44
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Oct 27 23:59:29 2024 -0500

    [mm]: Improve `VERBON` argument validation.
    
    * contrib/mm/m.tmac (VERBON): Improve argument validation.  Error out if
      (optional) first argument is non-numeric, otherwise populate
      `misc*verb` register as before.
    
      (VERBON, VERBOFF): Stop prefixing `misc*verb` register interpolations
      with literal zeroes.  This appears to have been a copy-and-paste of an
      old troff idiom for interpolating _strings_ (or macro arguments).  But
      a register's interpolation is always valid in a numeric expressions
      (unless someone fiddles its register format, which shouldn't happen to
      `misc*verb`).
---
 contrib/mm/ChangeLog | 12 ++++++++++++
 contrib/mm/m.tmac    | 27 ++++++++++++++++-----------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index 4ad28589b..bb127f2b5 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,15 @@
+2024-10-27  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * m.tmac (VERBON): Improve argument validation.  Error out if
+       {optional} first argument is non-numeric, otherwise populate
+       `misc*verb` register as before.
+       (VERBON, VERBOFF): Stop prefixing `misc*verb` register
+       interpolations with literal zeroes.  This appears to have been a
+       copy-and-paste of an old troff idiom for interpolating _strings_
+       {or macro arguments}.  But a register's interpolation is always
+       valid in a numeric expressions {unless someone fiddles its
+       register format, which shouldn't happen to `misc*verb`}.
+
 2024-10-27  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * mm/ms.cov (cov@print-authors): Stop erroring out if no authors
diff --git a/contrib/mm/m.tmac b/contrib/mm/m.tmac
index 5a1b08474..1dd383d87 100644
--- a/contrib/mm/m.tmac
+++ b/contrib/mm/m.tmac
@@ -847,8 +847,8 @@ hd*last-hsize=\\n[hd*last-hsize]u
 .rm misc*rd misc*rd2
 ..
 .\"------------
-.\" VERBON [flag [type-size [font]]]
-.\"    flag
+.\" VERBON [format [type-size [font]]]
+.\"    format
 .\"    bit     function
 .\"    0       escape character disablement
 .\"    1       add an empty line before verbatim text
@@ -857,23 +857,28 @@ hd*last-hsize=\\n[hd*last-hsize]u
 .\"    4       indent text by amount in register Verbin
 .de VERBON
 \\*[debug@dump-args]\\
+.nr misc*verb 0
+.if !'\\$1'' \{\
+.      ie \B'\\$2' .nr misc*verb \\$1
+.      el          .@error \\$0: format argument is not numeric; got \
+'\\$1'
+.\}
 .br
-.nr misc*verb 0\\$1
-.if (0\\n[misc*verb]%4)/2 .SP \\n[Lsp]u
+.if (\\n[misc*verb]%4)/2 .SP \\n[Lsp]u
 .misc@ev-keep misc*verb-ev
 .nf
-.if (0\\n[misc*verb]%16)/8 .nm \\*[Verbnm]
+.if (\\n[misc*verb]%16)/8 .nm \\*[Verbnm]
 .ie !'\\$3'' .if F \\$3 .ft \\$3
 .el          .if F CR   .ft CR
-.ie 0\\$2 \{\
+.ie !'\\$2'' \{\
 .      ss \\$2
 .      ps \\$2
 .      vs \\$2
 .\}
 .el .ss 12
 .ta T 8u*\w@n@u
-.if (0\\n[misc*verb]%32)/16 .in +\\n[Verbin]u
-.if 0\\n[misc*verb]%2 \{\
+.if (\\n[misc*verb]%32)/16 .in +\\n[Verbin]u
+.if \\n[misc*verb]%2 \{\
 .      eo
 .      nr @in-verbatim-region 1
 .\}
@@ -881,9 +886,9 @@ hd*last-hsize=\\n[hd*last-hsize]u
 .de VERBOFF
 .ec
 .br
-.if (0\\n[misc*verb]%8)/4 .SP \\n[Lsp]u
-.if (0\\n[misc*verb]%16)/8 .nm
-.if (0\\n[misc*verb]%32)/16 .in
+.if (\\n[misc*verb]%8)/4 .SP \\n[Lsp]u
+.if (\\n[misc*verb]%16)/8 .nm
+.if (\\n[misc*verb]%32)/16 .in
 .ev
 .nr @in-verbatim-region 0
 ..



reply via email to

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