summaryrefslogtreecommitdiff
path: root/ACE/bin/clean_dsp.pl
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/bin/clean_dsp.pl')
-rwxr-xr-xACE/bin/clean_dsp.pl52
1 files changed, 52 insertions, 0 deletions
diff --git a/ACE/bin/clean_dsp.pl b/ACE/bin/clean_dsp.pl
new file mode 100755
index 00000000000..9f3f54e63c8
--- /dev/null
+++ b/ACE/bin/clean_dsp.pl
@@ -0,0 +1,52 @@
+# $Id$
+# DSP cleaner
+
+$if_depth = 0;
+@saved_lines = ();
+$dirty = 0;
+$in_dependency = 0;
+
+die "Not enough args" if ($#ARGV < 0);
+
+open (FILE, "<$ARGV[0]");
+
+loop: while (<FILE>)
+{
+ # Check for dependency information
+
+ if (/^DEP/ || /^NODEP/) {
+ $in_dependency = 1;
+ }
+
+ if ($in_dependency) {
+ $in_dependency = 0 if (!/\\$/);
+ goto loop;
+ }
+
+ # Check for empty !IF blocks
+
+ if (/^\!IF/) {
+ ++$if_depth;
+ }
+
+ push @saved_lines, $_
+ if ($if_depth > 0);
+
+ if (/^\!ENDIF/) {
+ --$if_depth;
+ print @saved_lines
+ if ($if_depth == 0 && $dirty == 1);
+ @saved_lines = ();
+ $dirty = 0;
+ }
+ elsif ($if_depth == 0) {
+ print;
+ }
+
+ $dirty = 1
+ if ($if_depth > 0 && !/^\!/ && !/^\s+$/);
+
+
+}
+
+close (FILE);