[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 17/30: [mm]: Validate `LB` macro's 5th argument.
From: |
G. Branden Robinson |
Subject: |
[groff] 17/30: [mm]: Validate `LB` macro's 5th argument. |
Date: |
Thu, 10 Oct 2024 20:18:12 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit c243961bcecdde89d9678223d5d1ef6a76131a67
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Oct 9 23:41:01 2024 -0500
[mm]: Validate `LB` macro's 5th argument.
* contrib/mm/m.tmac (LB): Validate fifth (mark-or-format) argument.
Getting it wrong leads to surprising formatter diagnostics. Since
we're (ultimately) passing it to the `af` request, ensure that it's a
nonnegative integer or in the set {a,A,i,I}.
The extra indentation is to make the next commit less noisy.
---
contrib/mm/ChangeLog | 7 +++++++
contrib/mm/m.tmac | 15 ++++++++++++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/contrib/mm/ChangeLog b/contrib/mm/ChangeLog
index 9109e80b3..b39568d01 100644
--- a/contrib/mm/ChangeLog
+++ b/contrib/mm/ChangeLog
@@ -1,3 +1,10 @@
+2024-10-09 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * m.tmac (LB): Validate fifth (mark-or-format) argument.
+ Getting it wrong leads to surprising formatter diagnostics.
+ Since we're (ultimately) passing it to the `af` request, ensure
+ that it's a nonnegative integer or in the set {a,A,i,I}.
+
2024-10-09 G. Branden Robinson <g.branden.robinson@gmail.com>
* m.tmac: Refactor reference list formatting.
diff --git a/contrib/mm/m.tmac b/contrib/mm/m.tmac
index 24a581623..896444b73 100644
--- a/contrib/mm/m.tmac
+++ b/contrib/mm/m.tmac
@@ -2352,7 +2352,20 @@ breaking page
.nr li*cnt!\\n[li*lvl] 0 1
.\" assign format
.af li*cnt!\\n[li*lvl] 1
-.if \\n[li*type] .if !'\\*[li*mf]'' .af li*cnt!\\n[li*lvl] \\*[li*mf]
+.if \\n[li*type] \{\
+. nr li*is-format-valid 0
+. if \B'\\*[li*mf]'&\\*[li*mf]>-1 .nr li*is-format-valid 1
+. if '\?\\*[li*mf]\?'\?a\?' .nr li*is-format-valid 1
+. if '\?\\*[li*mf]\?'\?A\?' .nr li*is-format-valid 1
+. if '\?\\*[li*mf]\?'\?i\?' .nr li*is-format-valid 1
+. if '\?\\*[li*mf]\?'\?i\?' .nr li*is-format-valid 1
+. if !\\n[li*is-format-valid] \{\
+. @warning \\$0: type argument is \\n[li*type] \
+but mark argument '\\*[li*mf]' is not a valid register format; \
+assuming '0'
+. ds li*mf 0\"
+. \}
+.\}
.\"
.if \\n[li*lb-spc] .SP (u;\\n[li*lb-spc]*\\n[Lsp])
.in +\\n[li*tind]u
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 17/30: [mm]: Validate `LB` macro's 5th argument.,
G. Branden Robinson <=