Debian Codegraph @

bin/build/cleancrlf

raw
1 #!/usr/bin/perl
2
3 ############################################################################
4 # This file is part of FreeFEM. #
5 # #
6 # FreeFEM is free software: you can redistribute it and/or modify #
7 # it under the terms of the GNU Lesser General Public License as #
8 # published by the Free Software Foundation, either version 3 of #
9 # the License, or (at your option) any later version. #
10 # #
11 # FreeFEM is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU Lesser General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU Lesser General Public License #
17 # along with FreeFEM. If not, see <http://www.gnu.org/licenses/>. #
18 ############################################################################
19 # SUMMARY : ...
20 # LICENSE : LGPLv3
21 # ORG : LJLL Universite Pierre et Marie Curie, Paris, FRANCE
22 # AUTHORS : Antoine Le Hyaric
23 # E-MAIL : ...
24
25 # clean-up all CR/LF line endings (usually before patching to avoid failures after editing the same source files on
26 # different systems)
27
28 use strict;
29
30 # change files that have been recorded in FF using DOS line endings
31 my @files=`find $ARGV[0] -type f`;
32 chomp @files;
33 foreach my $file(@files){
34 next if $file=~/\.(jpg|eps|mcp|pdf|pgm|o|a|so|png|jpg|gz|tgz)$/;
35 next if $file=~/\.hg\//;
36 my $contents=`cat $file`;
37 my $oldcontents=$contents;
38
39 # changing line-ending conventions. all ffcs patches work from unix-style (ie no CR) files
40
41 $contents=~s/\r$//gm;
42 next if $contents eq $oldcontents;
43 print "cleancrlf: Unix line-ending for $file...\n";
44 open FILE,">$file" or die;
45 print FILE $contents;
46 close FILE;
47 }
48
49 # Local Variables:
50 # mode:cperl
51 # ispell-local-dictionary:"british"
52 # coding:utf-8
53 # End: