From 0ef1c73ac1c22c44483bbc3ec8f0ea92963bced8 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 21 Dec 2020 16:38:01 -0500 Subject: Move rfc to doc/rfc --- doc/rfc/rfctags.pl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 doc/rfc/rfctags.pl (limited to 'doc/rfc/rfctags.pl') diff --git a/doc/rfc/rfctags.pl b/doc/rfc/rfctags.pl new file mode 100644 index 00000000..01324a0d --- /dev/null +++ b/doc/rfc/rfctags.pl @@ -0,0 +1,28 @@ +use strict; +use warnings; +use open ':encoding(ISO-8859-1)'; + +use IO::Uncompress::Gunzip qw($GunzipError); + +($,, $\) = ("\t", "\n"); +print '!_TAG_FILE_SORTED', 2, $0; # Promise to pipe this through sort -f +for my $rfc (<*.txt.gz>) { + my $handle = new IO::Uncompress::Gunzip $rfc + or die "${rfc}: ${GunzipError}"; + while (<$handle>) { + chomp; + # Section headings + if (/^([\d.]+|[A-Z][.])\s+([^\t]+)?/) { + print $1, $rfc, $.; + print $2, $rfc, $. if $2; + print $1, $rfc, $. if $1 =~ /^([\d.]+)[.]$/; + } + # References + if (/^\s*(\[[\w-]+\])\s{2,}/) { + print $1, $rfc, $.; + print "\\$1", $rfc, $.; # vim ^] prepends \ to [ + } + } + die "${rfc}: $!" if $!; + close $handle; +} -- cgit 1.4.1