Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove any reference to mergesort.
[simgrid.git] / tools / spell / lspell.pl
1 #!/bin/perl
2
3 # C comment 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!//(.+)$!check_content($1)!egm;
32         $content =~ s!/\*(.+?)\*/!check_content($1)!egs;
33         close(POUT);
34
35         open(PIN, "ispell -d american -l < $TEMPFILE | sort -uf |") || die;
36         undef @badwords;
37         while (<PIN>) {
38                 chomp;
39                 if ($stopped{$_} == 0) {
40                         push(@badwords, $_);
41                 }
42         }
43         close(PIN) || die;
44
45         if (@badwords) {
46                 print "$file: ".scalar(@badwords)."\n\n";
47                 print join(" ",@badwords)."\n\n";
48         }
49 }