split-man.pl 604 B

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