Subversion Repositories wimsdev

Rev

Rev 11930 | Rev 12188 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. #!/usr/bin/perl -w
  2.  
  3.  
  4. use strict "vars";
  5. use strict "subs";
  6. use locale;
  7. use warnings;
  8. #$/ = undef;
  9.  
  10. my $warning1='is the first character of a delimiter but occurred as data';
  11. my $warning2="info: line \$";
  12. my $warning21=": character \"&\" is the first character of a delimiter but occurred as data";
  13. my $DIR=".";
  14. my $option='';
  15. while ($_ = shift(@ARGV))
  16. {
  17.   last if (/^$/);
  18.   if (/^--option=(.*)$/)  { $option = $1}
  19.   elsif  (/^--dir=(.*)$/)   {$DIR = $1 }
  20. }
  21. my @Files = GetFilesList ($DIR);
  22. foreach my $File  (@Files) {
  23.         treate($File);
  24.         if($option==1){ treate2($File)};
  25. }
  26.  
  27. sub treate { my ($file)=@_;
  28.   my $text='';
  29.   open(IN,$file);
  30.   while (<IN>) {
  31.    next if (/$warning1/);
  32.    next if (/$warning2\d+$warning21/);
  33.    next if (/no attribute "autocompletion"/);
  34.    next if (/no attribute "autocomplete"/);
  35.    next if (/validating: test.html/);
  36.    $text .= $_;
  37.   }
  38.   close IN;
  39.   out($file, $text);
  40. }
  41.  
  42. sub treate2 { my ($file)=@_;
  43.   my $text='';
  44.   open(IN,$file);
  45.   while (<IN>) {
  46.    next if (/start tag was here/);
  47.    ##next if (/value of attribute "type" cannot be "search"/);
  48.    ##next if (/there is no attribute "results"/);
  49.    ## next if (/there is no attribute "placeholder"/);
  50.    next if (/there is no attribute "name"/);
  51.    ##next if (/there is no attribute "type"/);
  52.    next if (/Attribute "results" not allowed on element "input" at this point/);
  53.    next if (/Attribute “results” not allowed on element “input” at this point/);
  54.    next if (/document type does not allow element "style" here/);
  55.    next if (/document type does not allow element "div" here\s*END/); ## last in the result come from the debug
  56.    next if (/document type does not allow element "link" here/);
  57.    next if (/Legacy encoding "windows-1252" used. Documents should use UTF-8/);
  58.    next if (/Legacy encoding “windows-1252” used. Documents should use UTF-8/);
  59.    next if (/Cannot recover after last error. Any further errors will be ignored./);
  60.    next if (/Stray start tag “div”./);
  61.    next if (/Stray start tag "div"./);
  62.    $text .= $_;
  63.   };
  64.   close IN;
  65.   $text =~ s/line \d+://g;
  66.   $text =~ s/END//g;
  67.   $text =~ s/\n{2,}/\n/g;
  68.   if ($text =~ /error|info/) {  } else { $text='' };
  69.   out($file, $text);
  70. }
  71.  
  72. sub out { my ($bloc, $text) = @_;
  73.   open  (OUT, ">$bloc") || warn "peut pas créer $bloc";
  74.   print OUT $text; close OUT;
  75.   system (`rm $bloc`) if(!$text);
  76. }
  77.  
  78. sub GetFilesList
  79. {
  80.         my $Path = $_[0];
  81.         my $FileFound;
  82.         my @FilesList=();
  83.  
  84.         # Lecture de la liste des fichiers
  85.         opendir (my $FhRep, $Path)
  86.                 or die "Impossible d'ouvrir le repertoire $Path\n";
  87.         my @Contenu = grep { !/^\.\.?$/ } readdir($FhRep);
  88.         closedir ($FhRep);
  89.  
  90.         foreach my $FileFound (@Contenu) {
  91.                 # Traitement des fichiers
  92.                 if ( -f "$Path/$FileFound") {
  93.                         push ( @FilesList, "$Path/$FileFound" );
  94.                 }
  95.                 # Traitement des repertoires
  96.                 elsif ( -d "$Path/$FileFound") {
  97.                         # Boucle pour lancer la recherche en mode recursif
  98.                         push (@FilesList, GetFilesList("$Path/$FileFound") );
  99.                 }
  100.         }
  101.         return @FilesList;
  102. }
  103.