# BEGIN rule(s)
BEGIN {
1 if (sortcmd == "") {
sortcmd = "sort"
}
1 asplit("BEGIN:END:atan2:break:close:continue:cos:delete:" "do:else:exit:exp:for:getline:gsub:if:in:index:int:" "length:log:match:next:print:printf:rand:return:sin:" "split:sprintf:sqrt:srand:sub:substr:system:while", keywords, ":")
1 split("00:00:00:00:00:00:00:00:00:00:" "20:10:10:12:12:11:07:00:00:00:" "08:08:08:08:08:33:08:00:00:00:" "08:44:08:36:08:08:08:00:00:00:" "08:44:45:42:42:41:08", machine, ":")
1 state = 1
570 for (;;) {
570 symb = lex()
570 nextstate = substr(machine[state symb], 1, 1)
570 act = substr(machine[state symb], 2, 1)
570 if (act == "0") { # 12
558 } else if (act == "1") { # 8
8 if (! inarray(tok, names)) { # 3
3 names[++nnames] = tok
}
8 lines[tok, ++xnames[tok]] = NR
550 } else if (act == "2") { # 425
425 if (tok in local) { # 309
309 tok = tok "(" funcname ")"
309 if (! inarray(tok, names)) { # 22
22 names[++nnames] = tok
}
309 lines[tok, ++xnames[tok]] = NR
116 } else {
116 tok = tok "()"
116 if (! inarray(tok, names)) { # 21
21 names[++nnames] = tok
}
116 lines[tok, ++xnames[tok]] = NR
}
125 } else if (act == "3") { # 4
4 funcname = tok
4 flines[tok] = NR
121 } else if (act == "4") { # 49
49 braces++
72 } else if (act == "5") { # 49
49 braces--
49 if (braces == 0) { # 4
22 for (temp in local) {
22 delete local[temp]
}
4 funcname = ""
4 nextstate = 1
}
23 } else if (act == "6") { # 22
22 local[tok] = 1
1 } else if (act == "7") { # 1
1 break
} else if (act == "8") {
print("error: xref.awk: line " NR ": aborting") > "/dev/con"
exit 1
}
569 state = nextstate
}
46 for (i = 1; i <= nnames; i++) {
46 printf("%d ", xnames[names[i]]) | sortcmd
46 if (index(names[i], "(") == 0) { # 3
3 printf("%s(%d)", names[i], flines[names[i]]) | sortcmd
43 } else {
43 printf("%s", names[i]) | sortcmd
}
433 for (j = 1; j <= xnames[names[i]]; j++) {
433 if (lines[names[i], j] != lines[names[i], j - 1]) { # 389
389 printf(" %d", lines[names[i], j]) | sortcmd
}
}
46 printf("\n") | sortcmd
}
1 close(sortcmd)
}
# Functions, listed alphabetically
1 function asplit(str, arr, fs, n)
{
1 n = split(str, temp_asplit, fs)
36 for (i = 1; i <= n; i++) {
36 arr[temp_asplit[i]]++
}
}
433 function inarray(val, arr, j, tmp)
{
15872 for (j in arr) {
15872 tmp[arr[j]]++
}
433 return (val in tmp)
}
570 function lex()
{
1698 for (;;) {
1698 if (tok == "(eof)") {
return 7
}
326 while (length(line) == 0) {
326 if ((getline line) == 0) { # 1
1 tok = "(eof)"
1 return 7
}
}
1697 sub(/^[ \t]+/, "", line)
1697 sub(/^"([^"]|\\")*"/, "", line)
1697 sub(/^\/([^\/]|\\\/)+\//, "", line)
1697 sub(/^#.*/, "", line)
1697 if (line ~ /^function/) { # 4
4 tok = "function"
4 line = substr(line, 9)
4 return 1
1693 } else if (line ~ /^{/) { # 53
53 tok = "{"
53 line = substr(line, 2)
53 return 2
1640 } else if (line ~ /^}/) { # 53
53 tok = "}"
53 line = substr(line, 2)
53 return 3
1587 } else if (match(line, /^[[:alpha:]_][[:alnum:]_]*\[/)) { # 43
43 tok = substr(line, 1, RLENGTH - 1)
43 line = substr(line, RLENGTH + 1)
43 return 5
1544 } else if (match(line, /^[[:alpha:]_][[:alnum:]_]*\(/)) { # 87
87 tok = substr(line, 1, RLENGTH - 1)
87 line = substr(line, RLENGTH + 1)
87 if (! (tok in keywords)) { # 12
12 return 6
}
1457 } else if (match(line, /^[[:alpha:]_][[:alnum:]_]*/)) { # 521
521 tok = substr(line, 1, RLENGTH)
521 line = substr(line, RLENGTH + 1)
521 if (! (tok in keywords)) { # 404
404 return 4
}
936 } else {
936 match(line, /^[^[:alpha:]_{}]/)
936 tok = substr(line, 1, RLENGTH)
936 line = substr(line, RLENGTH + 1)
}
}
}