http://qs1969.pair.com?node_id=9150
Category: C coding tools
Author/Contact Info djp: parksdj@miavx1.acs.muohio.edu
Description:

Do you get sick of sorting through all those conditional compilation statems of the form:


   #ifdef DEBUG
   /* C code here *.
   #endif

This short script will strip them out, making your C code more legible. Use input redirection to run your *.c files through this filtering program.

#!/usr/bin/perl -w
#
# nodebug.pl -- strips the "#ifdef YOUR_DEBUG ... #endif"
# out of C proggies

use strict;

my $state = 0;

while(<>) {
  if( ($state == 0) && ($_ =~ /#if.*DEBUG/) ) {
    $state = 1;
  }
  if( $state == 0 ) {
    print $_;
  }
  if( ($state == 1) && ($_ =~ /#endif/) ) {
    $state = 0;
  }
}