[r23]: LIME-core / lib / imp2hdr.awk Maximize Restore History

Download this file

imp2hdr.awk    45 lines (44 with data), 1.2 kB

 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
#!/usr/bin/awk -f
##################################################################
# This AWK scripts performs depth-first search and inclusion
#
#Copyright 2008 Pjotr Kourzanov
#
#This file is part of LIME.
#
#LIME is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License version 2
#as published by the Free Software Foundation.
#
#LIME is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with LIME. If not, see <http://www.gnu.org/licenses/>.
##################################################################
func dump(x) {
gsub(suff "$","",x)
if (do_includes) {
print "#include <" x ".h>"
return
}
print x
}
BEGIN {
suff=(suff ? suff : ".imports")
file[++i]=ARGV[1]
done[file[i]]=1
for (;i>0;i--) {
while ((getline < (file[i]))>0) {
f=$0 suff
if (f in done) continue
done[f]=1
file[++i]=f
if (preorder) dump(file[i])
}
if (postorder && i>1) dump(file[i])
close(file[i]);
}
}