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 postfix_is('.ser', $file) ||
25 postfix_is('.tgz', $file) ||
26 postfix_is('.patch', $file) ||
27 postfix_is('.dtd', $file) ||
28 postfix_is('.ent', $file) ||
29 postfix_is('.png', $file) ||
30 postfix_is('.ico', $file) ||
32 postfix_is('.vtest', $file) ||
33 postfix_is('.svg', $file) ||
34 postfix_is('.phpt', $file) ||
35 postfix_is('VERSION', $file) ||
36 postfix_is('WHATSNEW', $file) ||
37 postfix_is('FOCUS', $file) ||
39 postfix_is('.diff', $file) ||
40 postfix_is('.exp', $file) ||
41 postfix_is('.log', $file) ||
42 postfix_is('.out', $file) ||
44 $file == './library/HTMLPurifier/Lexer/PH5P.php' ||
45 $file == './maintenance/PH5P.php'
47 $ext = strrchr($file, '.');
49 postfix_is('README', $file) ||
50 postfix_is('LICENSE', $file) ||
51 postfix_is('CREDITS', $file) ||
52 postfix_is('INSTALL', $file) ||
53 postfix_is('NEWS', $file) ||
54 postfix_is('TODO', $file) ||
55 postfix_is('WYSIWYG', $file) ||
56 postfix_is('Changelog', $file)
58 if (postfix_is('Doxyfile', $file)) $ext = 'Doxyfile';
59 if (postfix_is('.php.in', $file)) $ext = '.php';
71 $line = '<!-- %s -->';
89 prefix_is('./library/HTMLPurifier/ConfigSchema', $file) ||
90 prefix_is('./smoketests/test-schema', $file) ||
91 prefix_is('./tests/HTMLPurifier/StringHashParser', $file)
103 throw new Exception('Unknown file: ' . $file);
107 $contents = file_get_contents($file);
109 $regex = '~' . str_replace('%s', 'vim: .+', preg_quote($line, '~')) . '~m';
110 $contents = preg_replace($regex, '', $contents);
112 $contents = rtrim($contents);
114 if (strpos($contents, "\r\n") !== false) $nl = "\r\n";
115 elseif (strpos($contents, "\n") !== false) $nl = "\n";
116 elseif (strpos($contents, "\r") !== false) $nl = "\r";
119 if (!$no_nl) $contents .= $nl;
120 $contents .= $nl . str_replace('%s', $vimline, $line) . $nl;
122 file_put_contents($file, $contents);
126 // vim: et sw=4 sts=4