more changes on original files
[linux-2.4.git] / scripts / split-man
1 #!/usr/bin/perl
2 #
3 #      split-man: create man pages from kernel-doc -man output
4 #
5 # Author:       Tim Waugh <twaugh@redhat.com>
6 # Modified by:  Christoph Hellwig <hch@infradead.org>
7 #
8
9 use strict;
10
11 die "$0: where do I put the results?\n" unless ($#ARGV >= 0);
12 die "$0: can't create $ARGV[0]: $!\n" unless mkdir $ARGV[0], 0777;
13
14 my $state = 0;
15
16 while (<STDIN>) {
17         s/&amp;(\w+)/\\fB\1\\fP/g; # fix smgl uglinesses
18         if (/^\.TH \"[^\"]*\" 9 \"([^\"]*)\"/) {
19                 close OUT unless ($state++ == 0);
20                 my $fn = "$ARGV[0]/$1.9";
21                 if (open OUT, ">$fn") {
22                         print STDERR "creating $fn\n";
23                 } else {
24                         die "can't open $fn: $!\n";
25                 }
26
27                 print OUT $_;
28         } elsif ($state != 0) {
29                 print OUT $_;
30         }
31 }
32
33 close OUT;