-
Notifications
You must be signed in to change notification settings - Fork 0
/
asmlist.awk
53 lines (49 loc) · 1.55 KB
/
asmlist.awk
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
function trimString(string) {
sub(/[ \t\r\n]+$/, "", string)
return string
}
function escapeTargetName(targetName) {
gsub(" ", "\\\\ ", targetName)
gsub("#", "\\\\#", targetName)
gsub("\$", "$$", targetName)
return targetName
}
BEGIN {
macroSummary = 0
assemblerSummary = 0
libraryName = ""
macroCount = 0
objectName = ""
}
{
line = $0
firstCharacter = substr(line, 1, 1)
if (firstCharacter == "1") {
macroSummary = index(line, "Macro and Copy Code Source Summary") != 0
assemblerSummary = index(line, "Diagnostic Cross Reference and Assembler Summary") != 0
}
if (macroSummary && firstCharacter == " ") {
line = substr(line, 7)
sourceName = substr(line, 1, 44)
sourceName = trimString(sourceName)
if (length(sourceName) > 0) {
libraryName = sourceName
}
if (substr(libraryName, 1, 1) != "/") {
next
}
memberCount = split(substr(line, 57), members, " ")
for (memberIndex = 1; memberIndex <= memberCount; memberIndex++) {
macros[macroCount++] = escapeTargetName(libraryName "/" members[memberIndex])
}
} else if (assemblerSummary && firstCharacter == " ") {
if (trimString(substr(line, 7, 8)) == "SYSLIN") {
objectName = escapeTargetName(trimString(substr(line, 16)))
}
}
}
END {
for (macroIndex = 0; macroIndex < macroCount; macroIndex++) {
print(objectName ": " macros[macroIndex])
}
}