-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindirectcall.awk
44 lines (35 loc) · 947 Bytes
/
indirectcall.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
# indirectcall.awk --- Demonstrate indirect function calls
# average --- return the average of the values in fields $first - $last
function average(first, last)
{
# sum = 0;
# for (i = first; i <= last; i++)
# sum += $i
return sum(first, last) / (last - first + 1)
}
# sum --- return the sum of the values in fields $first - $last
function sum(first, last, ret, i)
{
ret = 0;
for (i = first; i <= last; i++)
ret += $i
return ret
}
# For each record, print the class name and the requested statistics
{
class_name = $1
gsub(/_/, " ", class_name) # Replace _ with spaces
# find start
for (i = 1; i <= NF; i++) {
if ($i == "data:") {
start = i + 1
break
}
}
printf("%s:\n", class_name)
for (i = 2; $i != "data:"; i++) {
the_function = $i
printf("\t%s: <%s>\n", $i, @the_function(start, NF) "")
}
print ""
}