ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
remove-trailing-whitespace.php
Go to the documentation of this file.
1 #!/usr/bin/php
2 <?php
3 
4 chdir(dirname(__FILE__));
5 require_once 'common.php';
6 assertCli();
7 
13 chdir(dirname(__FILE__) . '/..');
14 $FS = new FSTools();
15 
16 $files = $FS->globr('.', '{,.}*', GLOB_BRACE);
17 foreach ($files as $file) {
18  if (
19  !is_file($file) ||
20  prefix_is('./.git', $file) ||
21  prefix_is('./docs/doxygen', $file) ||
22  postfix_is('.ser', $file) ||
23  postfix_is('.tgz', $file) ||
24  postfix_is('.patch', $file) ||
25  postfix_is('.dtd', $file) ||
26  postfix_is('.ent', $file) ||
27  $file == './library/HTMLPurifier/Lexer/PH5P.php' ||
28  $file == './maintenance/PH5P.php'
29  ) continue;
30  $contents = file_get_contents($file);
31  $result = preg_replace('/^(.*?)[ \t]+(\r?)$/m', '\1\2', $contents, -1, $count);
32  if (!$count) continue;
33  echo "$file\n";
34  file_put_contents($file, $result);
35 }
36 
37 // vim: et sw=4 sts=4
$result
postfix_is($comp, $subject)
Definition: common.php:17
Filesystem tools not provided by default; can recursively create, copy and delete folders...
Definition: FSTools.php:10
prefix_is($comp, $subject)
Definition: common.php:12
assertCli()
Definition: common.php:3
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file