Debian Codegraph @

easel/devkit/man2optlist

raw
1 #! /usr/bin/perl
2
3
4 # man2optlist <.man file>
5 #
6 # From one of our "standardized" .man pages, generate a table
7 # that lists each documented option.
8 #
9 # Crosscomparisons with c2optlist and sqc2optlist allow verification
10 # that the options in a main .c file are documented in a .man page
11 # and tested in a .sqc unit test file.
12 #
13 # Options are looked for as a two-line sequence:
14 # .TP
15 # .B <-option>
16 # or
17 # .TP
18 # .BI <-option> " <optarg>"
19
20
21 while (<>)
22 {
23 if (/^\.TP/) { $nextline_is_option = 1; next; }
24
25 if ($nextline_is_option)
26 {
27 if (/^\.B\s+(-\S)\s*$/) { $option = $1; $optarg = "-"; }
28 elsif (/^\.B\s+(--\S+)\s*$/) { $option = $1; $optarg = "-"; }
29 elsif (/^\.BI\s+(-\S)\s+" (<[nxfcs]>)"\s*$/) { $option = $1; $optarg = $2; }
30 elsif (/^\.BI\s+(--\S+)\s+" (<[nxfcs]>)"\s*$/) { $option = $1; $optarg = $2; }
31 else { die "unrecognized option line:\n$_"; }
32
33 printf ("%-20s %s\n", $option, $optarg);
34 }
35
36 $nextline_is_option = 0;
37 }
38
39
40
41