Subversion Repositories wimsdev

Rev

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