Subversion Repositories wimsdev

Rev

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