Subversion Repositories wimsdev

Rev

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