Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use xbt_cfg_setdefault everywhere.
[simgrid.git] / tools / spell / lspell2.pl
1 #!/bin/perl
2
3 # C noncomment spell checker
4 # For each given source file, print the filename, a colon, and the number
5 # of misspelled words, then a list of misspelled words.
6 # Words contained in the file stopwords.txt are not considered spelling errors.
7 # Copyright 2003, Dan Kegel.  Licensed under GPL.  See the file ../COPYING for details.
8
9 sub check_content($) {
10         my $content = shift;
11         $content =~ tr/*/ /;
12         print POUT "$content\n";
13 }
14
15 $TEMPFILE="/tmp/spell.tmp";
16 $STOPFILE=shift(@ARGV);
17
18 open(STOPFILE, $STOPFILE) || die "can't open stopword file $STOPFILE";
19 while (<STOPFILE>) {
20         chomp;
21         $stopped{$_}++;
22 }
23 close(STOPFILE);
24
25 foreach $file (@ARGV) {
26         open (FI, $file) || die $file;
27         $content = join ("", <FI>);
28         close (FI);
29
30         open(POUT, "> $TEMPFILE") || die;
31         $content =~ s!//(.+)$! !gm;
32         $content =~ s!/\*(.+?)\*/! !gs;
33         print POUT $content;
34         close(POUT);
35
36         open(PIN, "ispell -d american -l < $TEMPFILE | sort -uf |") || die;
37         undef @badwords;
38         while (<PIN>) {
39                 chomp;
40                 if ($stopped{$_} == 0) {
41                         push(@badwords, $_);
42                 }
43         }
44         close(PIN) || die;
45
46         if (@badwords) {
47                 print "$file: ".scalar(@badwords)."\n\n";
48                 print join(" ",@badwords)."\n\n";
49         }
50 }