소스 검색

Merge branch 'fperrad-perlcritic' into develop

Karel Miko 8 년 전
부모
커밋
e96a895d0d
4개의 변경된 파일44개의 추가작업 그리고 31개의 파일을 삭제
  1. 15 15
      filter.pl
  2. 13 8
      fixupind.pl
  3. 3 0
      makefile
  4. 13 8
      parsenames.pl

+ 15 - 15
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 (<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;

+ 13 - 8
fixupind.pl

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

+ 3 - 0
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$

+ 13 - 8
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";