forked from surge-synthesizer/sst-basic-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_file_comments.pl
100 lines (85 loc) · 2.16 KB
/
fix_file_comments.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/perl
use File::Find;
use File::Basename;
find(
{
wanted => \&findfiles,
},
'include'
);
find(
{
wanted => \&findfiles,
},
'tests'
);
sub findfiles
{
$header = <<EOH;
/*
* sst-basic-blocks - an open source library of core audio utilities
* built by Surge Synth Team.
*
* Provides a collection of tools useful on the audio thread for blocks,
* modulation, etc... or useful for adapting code to multiple environments.
*
* Copyright 2023, various authors, as described in the GitHub
* transaction log. Parts of this code are derived from similar
* functions original in Surge or ShortCircuit.
*
* sst-basic-blocks is released under the GNU General Public Licence v3
* or later (GPL-3.0-or-later). The license is found in the "LICENSE"
* file in the root of this repository, or at
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* All source in sst-basic-blocks available at
* https://github.com/surge-synthesizer/sst-basic-blocks
*/
EOH
$f = $File::Find::name;
if ($f =~ m/\.h$/ or $f =~ m/.cpp$/)
{
#To search the files inside the directories
print "Processing $f\n";
$q = basename($f);
print "$q\n";
open(IN, "<$q") || die "Cant open IN $!";
open(OUT, "> ${q}.bak") || die "Cant open BAK $!";
$nonBlank = 0;
$inComment = 0;
while(<IN>)
{
if ($nonBlank)
{
print OUT
}
else
{
if (m:^\s*/\*:) {
$inComment = 1;
}
elsif (m:\s*\*/:)
{
print OUT $header;
$nonBlank = true;
$inComment = false;
}
elsif ($inComment)
{
}
elsif (m:^//:)
{
}
else
{
print OUT $header;
$nonBlank = true;
print OUT;
}
}
}
close(IN);
close(OUT);
system("mv ${q}.bak ${q}");
}
}