Updated italian translation
[midnight-commander.git] / maint / unrefglobals.pl
blob6af3f337a788847288003a65126b06f466f907f8
1 #!/usr/bin/perl
3 # Copyright (c) 2003, Pavel Roskin
4 # This script is Free Software, and it can be copied, distributed and
5 # modified as defined in the GNU General Public License. A copy of
6 # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
8 # Run this script on the map with cross-reference generated by GNU ld,
9 # and it will generate a list of symbols that don't need to be global.
10 # To create the map, run something like this:
11 # make LDFLAGS=-Wl,-Map,output.map,--cref
13 use strict;
15 my %symbols;
16 my %syms;
17 my %objs;
19 if ($#ARGV != 0) {
20 print "Usage: unrefglobals.pl mapfile\n";
21 exit 1;
24 if (!open (MAP, "$ARGV[0]")) {
25 print "Cannot open file \"$ARGV[0]\"\n";
26 exit 1;
29 my $line;
30 my $next_line = <MAP>;
31 while (1) {
32 last unless $next_line;
33 $line = $next_line;
34 $next_line = <MAP>;
35 next unless ($line =~ m{^[A-Za-z_][A-Za-z0-9_]* +[^ /][^ ]+\.o$} or
36 $line =~ m{^[A-Za-z_][A-Za-z0-9_]* +[^ /][^ ]+\.a\([^ ]+\.o\)$});
37 if (!$next_line or ($next_line !~ /^ /)) {
38 my @arr = split (' ', $line);
39 $symbols{$arr[0]} = $arr[1];
40 $syms{$arr[0]} = 1;
41 $objs{$arr[1]} = 1;
45 close(MAP);
47 foreach my $obj (sort keys %objs) {
48 print "$obj\n";
49 foreach my $sym (sort keys %syms) {
50 print "\t$sym\n" if ($symbols{$sym} eq $obj);