From 808616d40692dbcf37a0aab0551d0fe78f91a19e Mon Sep 17 00:00:00 2001 From: Francois Perrad Date: Sat, 25 Feb 2017 15:14:35 +0100 Subject: [PATCH] sanitize some Perl scripts (Perl4 is gone) --- filter.pl | 30 +++++++++++++++--------------- fixupind.pl | 21 +++++++++++++-------- makefile | 3 +++ parsenames.pl | 21 +++++++++++++-------- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/filter.pl b/filter.pl index 11ba62f..58b7584 100755 --- a/filter.pl +++ b/filter.pl @@ -2,29 +2,29 @@ # we want to filter every between START_INS and END_INS out and then insert crap from another file (this is fun) -$dst = shift; -$ins = shift; +use strict; +use warnings; -open(SRC,"<$dst"); -open(INS,"<$ins"); -open(TMP,">tmp.delme"); +open(my $src, '<', shift); +open(my $ins, '<', shift); +open(my $tmp, '>', 'tmp.delme'); -$l = 0; -while () { +my $l = 0; +while (<$src>) { if ($_ =~ /START_INS/) { - print TMP $_; + print {$tmp} $_; $l = 1; - while () { - print TMP $_; + while (<$ins>) { + print {$tmp} $_; } - close INS; + close $ins; } elsif ($_ =~ /END_INS/) { - print TMP $_; + print {$tmp} $_; $l = 0; } elsif ($l == 0) { - print TMP $_; + print {$tmp} $_; } } -close TMP; -close SRC; +close $tmp; +close $src; diff --git a/fixupind.pl b/fixupind.pl index 543ae96..ddefbd7 100755 --- a/fixupind.pl +++ b/fixupind.pl @@ -1,11 +1,16 @@ -open(IN,"crypt.ind.tmp"); -$a = ; -print OUT "$a\n\\addcontentsline{toc}{chapter}{Index}\n"; -while () { - print OUT $_; +#!/usr/bin/perl + +use strict; +use warnings; + +open(my $in, '<', 'crypt.ind'); +open(my $out, '>', 'crypt.ind.tmp'); +my $a = <$in>; +print {$out} "$a\n\\addcontentsline{toc}{chapter}{Index}\n"; +while (<$in>) { + print {$out} $_; } -close OUT; -close IN; +close $out; +close $in; system("mv -f crypt.ind.tmp crypt.ind"); diff --git a/makefile b/makefile index 5bf5241..2641a83 100644 --- a/makefile +++ b/makefile @@ -406,6 +406,9 @@ check_defines: | grep -v -e 'LTC_ECC[0-9]*' -e 'LTC_DH[0-9]*' -e 'LTC_NO_' -e 'LTC_MUTEX' -e 'LTC_MPI' \ | xargs -I '{}' sh -c 'grep -q -m 1 -o {} src/misc/crypt/crypt.c || echo {} not found' +perlcritic: + perlcritic *.pl + # $Source$ # $Revision$ # $Date$ diff --git a/parsenames.pl b/parsenames.pl index 8e6bc5e..cc2abed 100755 --- a/parsenames.pl +++ b/parsenames.pl @@ -4,20 +4,25 @@ # wrapped at 80 chars # # Tom St Denis -@a = split(" ", $ARGV[1]); -$b = "$ARGV[0]="; -$len = length($b); +use strict; +use warnings; + +my @a = split ' ', $ARGV[1]; +my $b = $ARGV[0] . '='; +my $len = length $b; print $b; foreach my $obj (@a) { - $len = $len + length($obj); + $len = $len + length $obj; $obj =~ s/\*/\$/; if ($len > 100) { - printf "\\\n"; - $len = length($obj); + print "\\\n"; + $len = length $obj; } - print "$obj "; + print $obj . ' '; +} +if ($ARGV[0] eq 'HEADERS') { + print 'testprof/tomcrypt_test.h'; } -if ($ARGV[0] eq "HEADERS") { print "testprof/tomcrypt_test.h"; } print "\n\n";