File: unused_functions.pl

package info (click to toggle)
emboss 6.6.0%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 571,544 kB
  • sloc: ansic: 460,579; java: 29,439; perl: 13,573; sh: 12,754; makefile: 3,283; csh: 706; asm: 351; xml: 239; pascal: 237; modula3: 8
file content (45 lines) | stat: -rwxr-xr-x 1,041 bytes parent folder | download | duplicates (10)
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
#!/usr/bin/perl -w

# Uses the EFUNC database to check for unused functions by module

open (MODS, "getz -lv '[efunc-mod:*]'|")
  || die "unable to list modules in EFUNC";

while (<MODS>) {
  if (!(/^\s+(\S+)\s+(\d+)/)) {
    print "Bad format returned by modules list:\n";
    print;
    next;
  }
  $mod = $1;
# $num = $2;
  open (AJAXMODS, "getz -c '[efunc-lib:ajax] & [efunc-mod:$mod]'|")
    || die "Cannot check modules in AJAX for $mod";
  $amods = <AJAXMODS>;
  close AJAXMODS;
  if (!defined($amods)) {
    $anum = 0;
#   print "$mod not in AJAX\n";
    next;
  }
  else {
    $anum = int($amods);
    print "$mod used in AJAX $anum times\n";
  }

####################################
# check for functions in this module
####################################

  open (AJAXFUN, "getz '[efunc-mod:$mod] ! [efunc-mod:$mod] < efunc_up'|")
	|| die "unable to list unused function names of module $mod";

  while (<AJAXFUN>) {
    /^EFUNC:(\S+)/;
    $fun = $1;
    print "Unused function $mod/$fun\n";
  }
 close AJAXFUN;

}
close MODS;