summaryrefslogtreecommitdiff
path: root/ipl/progs/fnctab.icn
blob: 669e379ee78b8e6eb7ee9b458300adb75e2ddc73 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
############################################################################
#
#	File:     fnctab.icn
#
#	Subject:  Program to list function usage
#
#	Author:   Ralph E. Griswold
#
#	Date:     June 18, 1994
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program processes an MVT token file and tabulates the usage
#  of functions.
#
#  Since function usage cannot be determined completely from static
#  analysis, the results should be viewed with this limitation in mind.
#
############################################################################

procedure main()
   local fncset, fnctab, line, count, name, total

   fncset := set()			# set for the names of all functions
   fnctab := table(0)			# table to tabulate function count

   total := 0

   every insert(fncset, function())
   delete(fncset, "args")		# ad hoc -- usual not used as functions
   delete(fncset, "name")

   while line := read() | stop("*** didn't find variable references") do {
      line ? {
         if ="Variable references:" then break
         }
      }


   while line := trim(read()) do {
      line ? {
         if tab(upto(&digits)) then {
            count := tab(many(&digits))
            tab(upto(&letters))
            name := tab(0)
            if name == "" then break
            if member(fncset, name) then {
               fnctab[name] +:= count
               total +:= count
               }
            }
         }
      }

   fnctab := sort(fnctab, 4)

   while count := pull(fnctab) do
      write(left(pull(fnctab), 14), right(count, 8))

   write()
   write("total         ", right(total, 8))

end