-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhawc.awk
More file actions
43 lines (34 loc) · 1.14 KB
/
Copy pathhawc.awk
File metadata and controls
43 lines (34 loc) · 1.14 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
BEGIN {
# we are just using awk to process whole lines; we don't want to split
# so we set FS to some garbage string we won't actually ever encounter
FS = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
IGNORECASE=1
currPrefix = ""
}
match($1, /\<url\(r'([^']*)'/, a) {
pattern = a[1]
# strip the leading "^" and the trailing "$"; visual noise for this report
if (match(pattern, /^\^(.*)/, goodParts)) { pattern = goodParts[1] }
if (match(pattern, /(.*)\$$/, goodParts)) { pattern = goodParts[1] }
# print pattern
currPrefix = pattern
}
# currPrefix tells us the start of the URL; next we need to see some other values
currPrefix != "" && match($0, /.*include\(.*/) {
chunk = $0
# we're looking at a prefix, now extract the "include(....)" value so we
# know the next file to look at
if (match(chunk, /.*include\('*([^)]*)'*).*/, a)) {
nextFile = a[1]
if (match(a[1], /(.*)',.*/, b)) {
nextFile = b[1]
}
if (match(nextFile, /(.*)'/, c)) {
nextFile = c[1]
}
# print currPrefix "\t" nextFile
print currPrefix
print nextFile
# system("echo " currPrefix " " nextFile " | awk -f /Users/tfeiler/development/shellScripts/hawc2.awk")
}
}