c25ce589dca10 (Finn Behrens 2020-11-23 15:15:33 +0100 1) #!/usr/bin/env perl
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 2) # SPDX-License-Identifier: GPL-2.0
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 3) #
3259081991a93 (Mauro Carvalho Chehab 2018-04-25 05:34:48 -0400 4) # Author: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 5) #
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 6) # Produce manpages from kernel-doc.
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 7) # See Documentation/doc-guide/kernel-doc.rst for instructions
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 8)
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 9) if ($#ARGV < 0) {
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 10) die "where do I put the results?\n";
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 11) }
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 12)
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 13) mkdir $ARGV[0],0777;
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 14) $state = 0;
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 15) while (<STDIN>) {
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 16) if (/^\.TH \"[^\"]*\" 9 \"([^\"]*)\"/) {
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 17) if ($state == 1) { close OUT }
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 18) $state = 1;
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 19) $fn = "$ARGV[0]/$1.9";
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 20) print STDERR "Creating $fn\n";
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 21) open OUT, ">$fn" or die "can't open $fn: $!\n";
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 22) print OUT $_;
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 23) } elsif ($state != 0) {
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 24) print OUT $_;
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 25) }
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 26) }
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 27)
5b229fbec89b9 (Matthew Wilcox 2018-02-13 13:15:35 -0800 28) close OUT;