repo.or.cz
/
smatch.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
locking: make spinlock_irqsave() work for my config
[smatch.git]
/
smatch_scripts
/
strip_whitespace.pl
blob
6c00e523a774e315c635269fb7930c98139aa9e4
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
"
;