#!/usr/bin/perl -n # # Convert a line like: # #include "foo.bar.h" # into 3 lines like: # #ifndef foo_bar_h # #include "foo.bar.h" # #endif # This handles the simplest case of a conditional #include. This isn't # really necessary, of course, if the programmer has done the usual # trick within foo.bar.h: # #ifndef foo_bar_h # #define foo_bar_h # ... # #endif # Still, it can be useful at times, especially as documentation, and # it does speed up compilation somewhat. # if (/#\s*include(\s+)"(.*)"/) { ($f = $2) =~ s/\W/_/g; print "#ifndef$1 $f\n"; print; print "#endif\n"; } else { print; }