<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># $Id: clean_dsp.pl 91813 2010-09-17 07:52:52Z johnnyw $
#   DSP cleaner

$if_depth = 0;
@saved_lines = ();
$dirty = 0;
$in_dependency = 0;

die "Not enough args" if ($#ARGV &lt; 0);

open (FILE, "&lt;$ARGV[0]");

loop: while  (&lt;FILE&gt;)
{
    # 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 &gt; 0);

    if (/^\!ENDIF/) {
        --$if_depth;
        print @saved_lines
            if ($if_depth == 0 &amp;&amp; $dirty == 1);
        @saved_lines = ();
        $dirty = 0;
    }
    elsif ($if_depth == 0) {
        print;
    }

    $dirty = 1
        if ($if_depth &gt; 0 &amp;&amp; !/^\!/ &amp;&amp; !/^\s+$/);


}

close (FILE);
</pre></body></html>