summary refs log tree commit diff
path: root/doc/rfc/rfctags.pl
blob: 05173d0093ab55b7e43e93d9dac60ab397dd6e7b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env perl
use strict;
use warnings;
use open ':encoding(ISO-8859-1)';

($,, $\) = ("\t", "\n");
while (<>) {
	chomp;
	# Section headings
	if (/^([\d.]+|[A-Z][.])\s+([^\t]+)?/) {
		print $1, $ARGV, $.;
		print $2, $ARGV, $. if $2;
		print $1, $ARGV, $. if $1 =~ /^([\d.]+)[.]$/;
	}
	# References
	if (/^\s*(\[[\w-]+\])\s{2,}/) {
		print $1, $ARGV, $.;
		print "\\$1", $ARGV, $.; # vim ^] prepends \ to [
	}
	close ARGV if eof;
}