Subversion Repositories wimsdev

Rev

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