File: add-outdated-warning.pl

package info (click to toggle)
manpages-de 0.7-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,188 kB
  • ctags: 9
  • sloc: makefile: 83; perl: 61
file content (47 lines) | stat: -rwxr-xr-x 917 bytes parent folder | download
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
46
47
#!/usr/bin/perl

use strict;
use warnings;

use File::Basename;

my $filename = fileparse($ARGV[0]);
(my $program, my $section) = split(/\./, $filename);

# Set up warning text
my $warning = <<WARNING;
.PP
Diese Handbuchseite ist eventuell veraltet. Im Zweifelsfall ziehen Sie
die englischsprachige Handbuchseite zu Rate, indem Sie
.IP
man -LC $section $program
.PP
eingeben.
WARNING

# Insert only once per file
my $inserted = 0;

# Read the whole file
while (<>) {
	# Match the first .SH section header
	if (!$inserted and /^\.SH\s+/) {
		# Print this section header
		print;
		# Read until next section header
		while (<>) {
			if (/^\.SH\s+/) {
				# Prepend the warning
				print $warning;
				# Remember that the warning is now inserted
				$inserted = 1;
				# Leave this inner loop and process rest of file
				last;
			}
			# Print lines for inner loop
			print;
		}
	}
	# Print non-matching lines
	print;
}