X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Fscript%2Ffix_modeline.pl;fp=src%2Fceph%2Fsrc%2Fscript%2Ffix_modeline.pl;h=8eadde9b54e5671e177b894e6d621e7e49ba462b;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/script/fix_modeline.pl b/src/ceph/src/script/fix_modeline.pl new file mode 100755 index 0000000..8eadde9 --- /dev/null +++ b/src/ceph/src/script/fix_modeline.pl @@ -0,0 +1,29 @@ +#!/usr/bin/perl + +use strict; +my $fn = shift @ARGV; +my $old = `cat $fn`; +my $header = `cat doc/modeline.txt`; + +# strip existing modeline +my $new = $old; +$new =~ s/^\/\/ \-\*\- ([^\n]+) \-\*\-([^\n]*)\n//s; # emacs +$new =~ s/^\/\/ vim: ([^\n]*)\n//s; # vim; +$new =~ s/^\/\/ \-\*\- ([^\n]+) \-\*\-([^\n]*)\n//s; # emacs +$new =~ s/^\/\/ vim: ([^\n]*)\n//s; # vim; +$new =~ s/^\/\/ \-\*\- ([^\n]+) \-\*\-([^\n]*)\n//s; # emacs +$new =~ s/^\/\/ vim: ([^\n]*)\n//s; # vim; + +# add correct header +$new = $header . $new; + +if ($new ne $old) { + print "$fn\n"; + open(O, ">$fn.new"); + print O $new; + close O; + system "diff $fn $fn.new"; + rename "$fn.new", $fn; + #unlink "$fn.new"; +} +