1 #!/usr/bin/perl
   2 
   3 use strict;
   4 
   5 my $file = shift();
   6 open FILE, "<$file";
   7 my $txt = do { local $/;  <FILE> };
   8 
   9 # strip C99 comments
  10 $txt =~ s/\/\/.*//g;
  11 # strip newlines
  12 $txt =~ s/\n//g;
  13 # strip remaining comments
  14 $txt =~ s/\/\*.*?\*\///g;
  15 # strip tabs
  16 $txt =~ s/\t//g;
  17 # strip spaces
  18 $txt =~ s/ //g;
  19 # add newlines
  20 $txt =~ s/;/;\n/g;
  21 $txt =~ s/{/{\n/g;
  22 $txt =~ s/}/}\n/g;
  23 
  24 print "$txt\n";