File: man2optlist

package info (click to toggle)
infernal 1.1.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 74,208 kB
  • sloc: ansic: 230,749; perl: 14,433; sh: 6,147; makefile: 3,071; python: 1,247
file content (41 lines) | stat: -rwxr-xr-x 1,047 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /usr/bin/perl


# man2optlist <.man file>
#
# From one of our "standardized" .man pages, generate a table
# that lists each documented option. 
#
# Crosscomparisons with c2optlist and sqc2optlist allow verification
# that the options in a main .c file are documented in a .man page
# and tested in a .sqc unit test file.
#
# Options are looked for as a two-line sequence:
#   .TP
#   .B <-option>
# or
#   .TP
#   .BI <-option> " <optarg>"


while (<>)
{
    if (/^\.TP/) { $nextline_is_option = 1; next; }

    if ($nextline_is_option) 
    {
	if     (/^\.B\s+(-\S)\s*$/)                    {  $option = $1; $optarg = "-"; }
	elsif  (/^\.B\s+(--\S+)\s*$/)	               {  $option = $1; $optarg = "-"; }
	elsif (/^\.BI\s+(-\S)\s+" (<[nxfcs]>)"\s*$/)   {  $option = $1; $optarg = $2;  }
	elsif (/^\.BI\s+(--\S+)\s+" (<[nxfcs]>)"\s*$/) {  $option = $1; $optarg = $2;  }
	else                                           { die "unrecognized option line:\n$_"; }

	printf ("%-20s %s\n", $option, $optarg);
    }

    $nextline_is_option = 0;
}