Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kate Hedstrom committed Oct 2, 2009
0 parents commit 51d319d
Show file tree
Hide file tree
Showing 108 changed files with 19,655 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Bin/cpp_clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/perl
#
# This script is used to clean CPP files. It removes:
#
# 1) Lines with '#' in column 1 (lines inserted by CPP).
# 2) Lines with '!!' in columns 1:2 (double commented lines).
# 3) Lines with '!$!' in columns 1:3 (removes OpenMP directives).
# 4) Blank lines.
# 5) Fixes placement of trailing '&'
#

my $file = $ARGV[0];
my $tmp = "tmp.$$";
open(FILE, "$file");
open(TMP, ">$tmp") || die "Can't open tmp file";

while (<FILE>) {
next if /^#/;
next if /^!!/;
next if /^!\$\!/;
next if /^\s*$/;
$a=rindex($_,"&");
if(/\&(\ )*$/ && $a!=72){
$l=length();
if($a<72){
$t=($a-1)-72;
$t2=-$t;
$sp="";
for($i=1;$i<$t2;$i++){
$sp=$sp . " ";
}
substr($_,-2,-$t-1)="$sp&\n";
}
if($a>72){
$t=72-($l);
substr($_,$t,-$t-1) = "&";
}
}
print TMP;
}
close(FILE);
close(TMP);

rename($tmp, $file);
Loading

0 comments on commit 51d319d

Please sign in to comment.