Yaffs site version 1.1
[yaffs-website] / vendor / ezyang / htmlpurifier / maintenance / remove-trailing-whitespace.php
1 #!/usr/bin/php
2 <?php
3
4 chdir(dirname(__FILE__));
5 require_once 'common.php';
6 assertCli();
7
8 /**
9  * @file
10  * Removes trailing whitespace from files.
11  */
12
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