Subversion Repositories wimsdev

Rev

Rev 12188 | Rev 16351 | 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 (/Legacy encoding /);
  60.    next if (/The only allowed value for the /);
  61.    next if (/Cannot recover after last error. Any further errors will be ignored./);
  62.    next if (/Stray start tag “div”./);
  63.    next if (/Stray start tag "div"./);
  64.    next if (/attribute is unnecessary for JavaScript resources./);
  65.    next if (/attribute for the “style” element is not needed and should be omitted./);
  66.    $text .= $_;
  67.   };
  68.   close IN;
  69.   $text =~ s/line \d+://g;
  70.   $text =~ s/END//g;
  71.   $text =~ s/\n{2,}/\n/g;
  72.   if ($text =~ /error|info/) {  } else { $text='' };
  73.   out($file, $text);
  74. }
  75.  
  76. sub out { my ($bloc, $text) = @_;
  77.   open  (OUT, ">$bloc") || warn "peut pas créer $bloc";
  78.   print OUT $text; close OUT;
  79.   system (`rm $bloc`) if(!$text);
  80. }
  81.  
  82. sub GetFilesList
  83. {
  84.         my $Path = $_[0];
  85.         my $FileFound;
  86.         my @FilesList=();
  87.  
  88.         # Lecture de la liste des fichiers
  89.         opendir (my $FhRep, $Path)
  90.                 or die "Impossible d'ouvrir le repertoire $Path\n";
  91.         my @Contenu = grep { !/^\.\.?$/ } readdir($FhRep);
  92.         closedir ($FhRep);
  93.  
  94.         foreach my $FileFound (@Contenu) {
  95.                 # Traitement des fichiers
  96.                 if ( -f "$Path/$FileFound") {
  97.                         push ( @FilesList, "$Path/$FileFound" );
  98.                 }
  99.                 # Traitement des repertoires
  100.                 elsif ( -d "$Path/$FileFound") {
  101.                         # Boucle pour lancer la recherche en mode recursif
  102.                         push (@FilesList, GetFilesList("$Path/$FileFound") );
  103.                 }
  104.         }
  105.         return @FilesList;
  106. }
  107.