sanitize some Perl scripts

(Perl4 is gone)
This commit is contained in:
Francois Perrad 2017-02-25 15:14:35 +01:00 committed by Karel Miko
parent 4cdc304e37
commit 808616d406
4 changed files with 44 additions and 31 deletions

View File

@ -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 (<SRC>) {
my $l = 0;
while (<$src>) {
if ($_ =~ /START_INS/) {
print TMP $_;
print {$tmp} $_;
$l = 1;
while (<INS>) {
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;

View File

@ -1,11 +1,16 @@
open(IN,"<crypt.ind");
open(OUT,">crypt.ind.tmp");
$a = <IN>;
print OUT "$a\n\\addcontentsline{toc}{chapter}{Index}\n";
while (<IN>) {
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");

View File

@ -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$

View File

@ -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";