File: genman

package info (click to toggle)
rplay 3.3.2-2
  • links: PTS
  • area: main
  • in suites: potato
  • size: 3,208 kB
  • ctags: 3,536
  • sloc: ansic: 42,124; makefile: 1,309; perl: 742; tcl: 345; sh: 301; java: 220
file content (45 lines) | stat: -rwxr-xr-x 809 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
42
43
44
45
#!/usr/bin/perl

$options = 0;

$in = $ARGV[0];
($progname, $section, $junk) = split ('\.', $in);
$out = "$progname.$section";

open (IN, "$in") || die "$in: $!";
open (OUT, ">$out") || die "$out: $!";

local ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime (time);
$mon++;
print OUT ".TH " . uc ($progname) . " $section" . " $mon/$mday/$year\n";

print STDERR "Generating $out...";
while (<IN>)
{
    print OUT;
    if (/^\.SH OPTIONS$/)
    {
	open (PROG, "$progname --help|") || die "$progname: $!";
	while (<PROG>)
	{
	    chop;
	    next if /^$/;
	    if (/^-/)
	    {
		s/-/\\-/g;
		print OUT ".TP\n.I \"$_\"\n";
		$options++;
	    }
	    elsif ($options)
	    {
		s/^\t//g;
		print OUT "$_\n";
	    }
	}
	close PROG;
    }
}
close OUT;
close IN;
print STDERR "done\n";
exit 0;