File: docmunge

package info (click to toggle)
libsnmp-info-perl 2.01-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,352 kB
  • ctags: 850
  • sloc: perl: 14,530; makefile: 15; sh: 1
file content (35 lines) | stat: -rwxr-xr-x 864 bytes parent folder | download | duplicates (9)
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
#!/usr/bin/perl -i.bak
#
# [Re-]write POD to create cross-links between Required MIBs, GLOBALS
#     and TABLE METHODS sections.
# This is a horrible jumble of heuristics, but works with
# all of the existing files. It has only one false positive: HP.pm's
# mention of an SNMP::Info version number.
#
$section = undef;
$waiting = 0;
while (<>) {
	if (eof) {
		$section = undef;
		$waiting = 0;
	}
	if (/^=head(\d)/) {
		$sl = $1;
		if ($sl <= $level) {
			$section = undef;
		}
		if (/(TABLE METHODS|GLOBALS|Required MIBs)/) {
			$section = $1;
			$level = $sl;
			if ($section eq 'TABLE METHODS' || $section eq 'GLOBALS') {
				$waiting = 1;
			}
		}
		if ($waiting && /imported/i) {
			$waiting = 0;
		}
	} elsif (defined($section) && !$waiting && /^[^=]/ && /SNMP::Info/) {
		s,(?:L<)?(SNMP::Info[a-zA-Z0-9:]*)(?:/[^>]+)?(?:>)?,L<$1/"$section">,g;
	}
	print;
}