Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / tools / internal / spell_comments.pl
index 4836fba..7494a16 100755 (executable)
@@ -1,6 +1,6 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
-# Copyright (c) 2013-2015. The SimGrid Team.
+# Copyright (c) 2013-2020. The SimGrid Team.
 # All rights reserved.
 
 # This program is free software; you can redistribute it and/or modify it
@@ -13,8 +13,9 @@
 # Copyright 2003, Dan Kegel.  Licensed under GPL.  See the file ../COPYING for details.
 
 use strict;
+use warnings;
 
-die "Please install iamerican to use that script.
+die "Please install iamerican to use that script.\n"
   unless (-r "/usr/lib/ispell/american.hash");
 
 sub check_content($) {
@@ -24,12 +25,15 @@ sub check_content($) {
 }
 
 my $TEMPFILE="/tmp/spell.tmp";
-my $DICTFILE="tools/spell_dict.txt";
-$DICTFILE="spell_dict.txt" unless (-e $DICTFILE);
+my $DICTFILE="tools/internal/spell_dict.txt";
+$DICTFILE="./spell_dict.txt" unless (-e $DICTFILE);
 die "Call this script from its location or from the SimGrid root directory\n" unless (-e $DICTFILE);
 
-die "Usage: ./spell_comments.pl `find ../ -name '*.[ch]' -name '*.hpp' -name '*.cpp'`\n"
-  unless length(@ARGV)>1;
+die "Usage: ". ($DICTFILE eq "./spell_dict.txt"? "./":"tools/internal/")."spell_comments.pl "
+           ."`find ". ($DICTFILE eq "./spell_dict.txt"? "../../":".")." -name '*.[ch]' -o -name '*.hpp' -o -name '*.cpp' |grep -v umpire|grep -v smpi/mpich3-test|grep -v NAS | grep -v src/smpi/colls`\n"
+  unless scalar(@ARGV)>0;
+
+my $total = 0;
 foreach my $file (@ARGV) {
        open (FI, $file) || die "Cannot open $file: $!\n";
        my $content = join ("", <FI>);
@@ -43,14 +47,17 @@ foreach my $file (@ARGV) {
        open(PIN, "ispell -d american -p $DICTFILE -l < $TEMPFILE | sort -uf |") || die;
        my @badwords;
        while (my $err = <PIN>) {
-           chomp $err;     
+           chomp $err; 
            push(@badwords, $err) if ($err =~ /\w/ && length($err)>0);
        }
        close(PIN) || die;
 
        if (@badwords) {
                print "$file: ".scalar(@badwords)." errors: '".join("','",@badwords)."'\n";
+               $total += scalar(@badwords);
        }
 }
 
-unlink($TEMPFILE);
\ No newline at end of file
+print "Total: $total\n";
+
+unlink($TEMPFILE);