[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #64205] [mm] `INITI` validates arguments poorly
From: |
G. Branden Robinson |
Subject: |
[bug #64205] [mm] `INITI` validates arguments poorly |
Date: |
Thu, 18 May 2023 04:45:03 -0400 (EDT) |
Follow-up Comment #1, bug #64205 (project groff):
Fixed in my working copy.
commit 813d91905a585673317c3beebc1380759ae91c49
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date: Thu May 18 03:38:54 2023 -0500
[mm]: Fix Savannah #64205.
[mm]: Improve input validation of `INITI`, `IND` macros.
* m.tmac (INITI): Validate the index type (first argument) here instead
of only later when `IND` is called. Actually verify that the second
argument is present and usable.
(IND): Verify that we're given arguments.
Fixes <https://savannah.gnu.org/bugs/?64205>.
Also make some design observations in comments.
Tested as follows using groff 1.22.4 and Git HEAD (on my branch).
$ cat EXPERIMENTS/test-index.sh
\#!/bin/sh
groff=./build/test-groff
groff=groff
printf '.INITI\n' | $groff -mm
printf '.INITI "" ""\n' | $groff -mm
printf '.INITI A ""\n' | $groff -mm
printf '.INITI N ""\n' | $groff -mm
printf '.INITI N myindex\n.INITI N myotherindex\n' | $groff -mm
printf '.IND foo\n' | $groff -mm
printf '.INITI N myindex\n.IND\n' | $groff -mm
printf '.INITI N myindex\n.IND ""\n' | $groff -mm
printf '.INITI N myindex\n.IND foo\n' | $groff -mm
$ sh EXPERIMENTS/test-index.sh
******************
ERROR:(<standard input>) input line 1:INITI:type missing
******************
"Input aborted, syntax error"
******************
ERROR:(<standard input>) input line 2:INITI:file already set
******************
"Input aborted, syntax error"
******************
ERROR:(<standard input>) input line 1:IND: No active INITI
******************
"Input aborted, syntax error"
Removing the second assignment to the "groff" shell variable...
$ sh EXPERIMENTS/test-index.sh
m.tmac:<standard input>:1: error: INITI: expected 2 or 3 arguments, got 0
m.tmac:<standard input>:1: error: INITI: invalid index type ''
m.tmac:<standard input>:1: error: INITI: invalid index type 'A'
m.tmac:<standard input>:1: error: INITI: index file name not specified
m.tmac:<standard input>:2: error: INITI: index file name already set
m.tmac:<standard input>:1: error: IND: no active index; call INITI first
m.tmac:<standard input>:2: error: IND: expected at least 1 argument, got
0
m.tmac:<standard input>:2: error: IND: cannot record empty index entry
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?64205>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/