Debian Codegraph @

doc/genman

raw
1 #!/usr/bin/perl
2
3 $options = 0;
4
5 $in = $ARGV[0];
6 ($progname, $section, $junk) = split ('\.', $in);
7 $out = "$progname.$section";
8
9 open (IN, "$in") || die "$in: $!";
10 open (OUT, ">$out") || die "$out: $!";
11
12 local ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime (time);
13 $mon++;
14 print OUT ".TH " . uc ($progname) . " $section" . " $mon/$mday/$year\n";
15
16 print STDERR "Generating $out...";
17 while (<IN>)
18 {
19 print OUT;
20 if (/^\.SH OPTIONS$/)
21 {
22 open (PROG, "$progname --help|") || die "$progname: $!";
23 while (<PROG>)
24 {
25 chop;
26 next if /^$/;
27 if (/^-/)
28 {
29 s/-/\\-/g;
30 print OUT ".TP\n.I \"$_\"\n";
31 $options++;
32 }
33 elsif ($options)
34 {
35 s/^\t//g;
36 print OUT "$_\n";
37 }
38 }
39 close PROG;
40 }
41 }
42 close OUT;
43 close IN;
44 print STDERR "done\n";
45 exit 0;