]> git.proxmox.com Git - ceph.git/blob - ceph/src/script/fix_modeline.pl
import 15.2.9
[ceph.git] / ceph / src / script / fix_modeline.pl
1 #!/usr/bin/perl
2
3 use strict;
4 my $fn = shift @ARGV;
5 my $old = `cat $fn`;
6 my $header = `cat doc/modeline.txt`;
7
8 # strip existing modeline
9 my $new = $old;
10 $new =~ s/^\/\/ \-\*\- ([^\n]+) \-\*\-([^\n]*)\n//s; # emacs
11 $new =~ s/^\/\/ vim: ([^\n]*)\n//s; # vim;
12 $new =~ s/^\/\/ \-\*\- ([^\n]+) \-\*\-([^\n]*)\n//s; # emacs
13 $new =~ s/^\/\/ vim: ([^\n]*)\n//s; # vim;
14 $new =~ s/^\/\/ \-\*\- ([^\n]+) \-\*\-([^\n]*)\n//s; # emacs
15 $new =~ s/^\/\/ vim: ([^\n]*)\n//s; # vim;
16
17 # add correct header
18 $new = $header . $new;
19
20 if ($new ne $old) {
21 print "$fn\n";
22 open(O, ">$fn.new");
23 print O $new;
24 close O;
25 system "diff $fn $fn.new";
26 rename "$fn.new", $fn;
27 #unlink "$fn.new";
28 }
29