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('FOCUS', $file) ||
39 postfix_is('configdoc/usage.xml', $file) ||
40 postfix_is('library/HTMLPurifier.includes.php', $file) ||
41 postfix_is('library/HTMLPurifier.safe-includes.php', $file) ||
42 postfix_is('smoketests/xssAttacks.xml', $file) ||
44 postfix_is('.diff', $file) ||
45 postfix_is('.exp', $file) ||
46 postfix_is('.log', $file) ||
47 postfix_is('.out', $file) ||
49 $file == './library/HTMLPurifier/Lexer/PH5P.php' ||
50 $file == './maintenance/PH5P.php'
52 $ext = strrchr($file, '.');
54 postfix_is('README', $file) ||
55 postfix_is('LICENSE', $file) ||
56 postfix_is('CREDITS', $file) ||
57 postfix_is('INSTALL', $file) ||
58 postfix_is('NEWS', $file) ||
59 postfix_is('TODO', $file) ||
60 postfix_is('WYSIWYG', $file) ||
61 postfix_is('Changelog', $file)
63 if (postfix_is('Doxyfile', $file)) $ext = 'Doxyfile';
64 if (postfix_is('.php.in', $file)) $ext = '.php';
76 $line = "<!-- %s\n-->";
94 prefix_is('./library/HTMLPurifier/ConfigSchema', $file) ||
95 prefix_is('./smoketests/test-schema', $file) ||
96 prefix_is('./tests/HTMLPurifier/StringHashParser', $file)
108 throw new Exception('Unknown file: ' . $file);
112 $contents = file_get_contents($file);
114 $regex = '~' . str_replace('%s', 'vim: .+', preg_quote($line, '~')) . '~m';
115 $contents = preg_replace($regex, '', $contents);
117 $contents = rtrim($contents);
119 if (strpos($contents, "\r\n") !== false) $nl = "\r\n";
120 elseif (strpos($contents, "\n") !== false) $nl = "\n";
121 elseif (strpos($contents, "\r") !== false) $nl = "\r";
124 if (!$no_nl) $contents .= $nl;
125 $contents .= $nl . str_replace('%s', $vimline, $line) . $nl;
127 file_put_contents($file, $contents);
131 // vim: et sw=4 sts=4