summaryrefslogtreecommitdiffstats
path: root/uClinux-2.4.31-uc0/scripts/split-man
blob: 04e2316cc8edf698306e1966c39e13d9a6ae6ab7 (plain)
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
#!/usr/bin/perl
#
#      split-man: create man pages from kernel-doc -man output
#
# Author:	Tim Waugh <twaugh@redhat.com>
# Modified by:	Christoph Hellwig <hch@infradead.org>
#

use strict;

die "$0: where do I put the results?\n" unless ($#ARGV >= 0);
die "$0: can't create $ARGV[0]: $!\n" unless mkdir $ARGV[0], 0777;

my $state = 0;

while (<STDIN>) {
	s/&amp;(\w+)/\\fB\1\\fP/g; # fix smgl uglinesses
	if (/^\.TH \"[^\"]*\" 9 \"([^\"]*)\"/) {
		close OUT unless ($state++ == 0);
		my $fn = "$ARGV[0]/$1.9";
		if (open OUT, ">$fn") {
			print STDERR "creating $fn\n";
		} else {
			die "can't open $fn: $!\n";
		}

		print OUT $_;
	} elsif ($state != 0) {
		print OUT $_;
	}
}

close OUT;