From: Mischa POSLAWSKY Date: Tue, 3 Apr 2012 18:07:54 +0000 (+0200) Subject: rfc1345convert: defer source download to makefile X-Git-Tag: v1.5~15 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/0d71f602a3268f8059dc48042280fb25c1abb4ba?hp=1a5ae8feefccb3f58ba09f069d45d0618a92cf8e rfc1345convert: defer source download to makefile --- diff --git a/Makefile b/Makefile index b44eaaa..23cdb70 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ all: unicode-char.inc.pl ttfsupport -digraphs.inc.pl: - ./rfc1345convert $(wildcard rfc1345.txt) >$@ +data/rfc1345.txt: + wget http://www.ietf.org/rfc/rfc1345.txt -O $@ + +digraphs.inc.pl: data/rfc1345.txt + ./rfc1345convert data/rfc1345.txt >$@ unicode-char.inc.pl: digraphs.inc.pl tools/convert-unicode.pl >$@ diff --git a/rfc1345convert b/rfc1345convert index 4fd3940..33b6ee9 100755 --- a/rfc1345convert +++ b/rfc1345convert @@ -7,32 +7,21 @@ use utf8; use open OUT => ':utf8', ':std'; use Data::Dumper; -our $VERSION = '1.01'; +our $VERSION = '1.02'; -# determine input data source -my $input; -if (@ARGV) { - # manual contents specified (either piped or filename(s) given) - $input = \*ARGV; -} -else { - # automatic download from official website - require LWP::Simple; - my $contents = LWP::Simple::get('http://www.ietf.org/rfc/rfc1345.txt') - or die "Couldn't download RFC-1345 from ietf.org"; - open $input, '<', \$contents; # emulate file handle -} +# expect input data source at command line +@ARGV or die "Specify input source file or - for STDIN\n"; # skip everything until a character indented by 1 space (table start) do { - $_ = readline $input; + $_ = readline; defined or die "Premature input end"; } until /^\s\S/; my @t = $_; # add first line (already read, assume it's ok) # read the rest of the character table -while ($_ = readline $input) { +while ($_ = readline) { # check for table end (chapter 4) last if /^\d/; @@ -184,18 +173,17 @@ rfc1345convert - Output digraph data from RFC-1345 =head1 SYNOPSIS -Download and convert the digraph specification from ietf.org: +Extract digraphs from text specifications as a perl hash: - rfc1345convert > digraphs.inc.pl + rfc1345convert rfc1345.txt custom.txt > digraphs.inc.pl -Test by printing the character for DO (should be a dollar sign): +Input can be the literal RFC (or similar) document: - perl -e'$di = do "digraphs.inc.pl"; print chr $di->{DO}->[0]' + curl http://www.ietf.org/rfc/rfc1345.txt | rfc1345convert - -Manual specification of source retrieval: +Test by printing the character for DO (should be a dollar sign): - rfc1345convert rfc1345.txt - curl $url | rfc1345convert - + perl -e'$di = do "digraphs.inc.pl"; print chr $di->{DO}->[0]' =head1 DESCRIPTION