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