Debian Codegraph @

pTk/findstrings

raw
1 #!/usr/local/bin/perl -w
2
3
4 %table = ();
5 %where = ();
6
7 sub notice
8 {
9 my ($index,$str) = @_;
10 ${$cur}[$index] = [] unless defined ${$cur}[$index];
11 my $array = ${$cur}[$index];
12 push(@$array,$str);
13 $where{$str} = [] unless defined $where{$str};
14 push (@{$where{$str}},$Func,$index);
15 }
16
17 while (<>)
18 {
19 if (defined $Func)
20 {
21 if (/^}/)
22 {
23 undef $Func;
24 undef $cur;
25 }
26 if (/strn?cmp\s*\(\s*LangString\(args\[(\d+)\]\)\s*,\s*("[^"]*")\s*/)
27 {
28 notice($1,$2);
29 }
30 elsif (/strn?cmp\s*\(\s*("[^"]*")\s*,LangString\(args\[(\d+)\]\)/)
31 {
32 notice($2,$1);
33 }
34 }
35 else
36 {
37 if (/^([A-Za-z][A-Za-z0-9_]*)\s*\(/)
38 {
39 $Func = "$ARGV:$1";
40 $table{$Func} = [] if (!defined $table{$Func});
41 $cur = $table{$Func};
42 }
43 }
44 }
45
46 foreach $Func (sort keys %table)
47 {
48 $cur = $table{$Func};
49 if (@{$cur})
50 {
51 print "$Func:\n";
52 my $i = 0;
53 for ($i = 0; $i < @{$cur}; $i++)
54 {
55 if (defined ${$cur}[$i])
56 {
57 my $array = ${$cur}[$i];
58 print " $i ",join(' ',@$array),"\n";
59 }
60 }
61 print "\n";
62 }
63 }
64
65 foreach $str (sort keys %where)
66 {
67 my $array = $where{$str};
68 my $i = 0;
69 print "$str:";
70 for ($i=0; $i < @{$array}; $i += 2)
71 {
72 print " ${$array}[$i](${$array}[$i+1])";
73 }
74 print "\n";
75 }