4 chdir(dirname(__FILE__
));
5 require_once 'common.php';
10 * Adds vimline to files
13 chdir(dirname(__FILE__
) . '/..');
16 $vimline = 'vim: et sw=4 sts=4';
18 $files = $FS->globr('.', '*');
19 foreach ($files as $file) {
22 prefix_is('./docs/doxygen', $file) ||
23 prefix_is('./library/standalone', $file) ||
24 prefix_is('./docs/specimens', $file) ||
25 postfix_is('.ser', $file) ||
26 postfix_is('.tgz', $file) ||
27 postfix_is('.patch', $file) ||
28 postfix_is('.dtd', $file) ||
29 postfix_is('.ent', $file) ||
30 postfix_is('.png', $file) ||
31 postfix_is('.ico', $file) ||
33 postfix_is('.vtest', $file) ||
34 postfix_is('.svg', $file) ||
35 postfix_is('.phpt', $file) ||
36 postfix_is('VERSION', $file) ||
37 postfix_is('WHATSNEW', $file) ||
38 postfix_is('configdoc/usage.xml', $file) ||
39 postfix_is('library/HTMLPurifier.includes.php', $file) ||
40 postfix_is('library/HTMLPurifier.safe-includes.php', $file) ||
41 postfix_is('smoketests/xssAttacks.xml', $file) ||
43 postfix_is('.diff', $file) ||
44 postfix_is('.exp', $file) ||
45 postfix_is('.log', $file) ||
46 postfix_is('.out', $file) ||
48 $file == './library/HTMLPurifier/Lexer/PH5P.php' ||
49 $file == './maintenance/PH5P.php'
51 $ext = strrchr($file, '.');
53 postfix_is('README', $file) ||
54 postfix_is('LICENSE', $file) ||
55 postfix_is('CREDITS', $file) ||
56 postfix_is('INSTALL', $file) ||
57 postfix_is('NEWS', $file) ||
58 postfix_is('TODO', $file) ||
59 postfix_is('WYSIWYG', $file) ||
60 postfix_is('Changelog', $file)
62 if (postfix_is('Doxyfile', $file)) $ext = 'Doxyfile';
63 if (postfix_is('.php.in', $file)) $ext = '.php';
75 $line = "<!-- %s\n-->";
93 prefix_is('./library/HTMLPurifier/ConfigSchema', $file) ||
94 prefix_is('./smoketests/test-schema', $file) ||
95 prefix_is('./tests/HTMLPurifier/StringHashParser', $file)
107 throw new Exception('Unknown file: ' . $file);
111 $contents = file_get_contents($file);
113 $regex = '~' . str_replace('%s', 'vim: .+', preg_quote($line, '~')) . '~m';
114 $contents = preg_replace($regex, '', $contents);
116 $contents = rtrim($contents);
118 if (strpos($contents, "\r\n") !== false) $nl = "\r\n";
119 elseif (strpos($contents, "\n") !== false) $nl = "\n";
120 elseif (strpos($contents, "\r") !== false) $nl = "\r";
123 if (!$no_nl) $contents .= $nl;
124 $contents .= $nl . str_replace('%s', $vimline, $line) . $nl;
126 file_put_contents($file, $contents);
130 // vim: et sw=4 sts=4