xref: /illumos-gate/usr/src/tools/smatch/src/smatch_scripts/strip_whitespace.pl (revision 241c90a06e8d1708235651863df515a2d522a03a)
1#!/usr/bin/perl
2
3use strict;
4
5my $file = shift();
6open FILE, "<$file";
7my $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
24print "$txt\n";
25