Ticket #2111: allow pause in copy/move/delete file operation.
[midnight-commander.git] / maint / unrefglobals.pl
blob0fb13fd569a2325b032e83760e821a2fba3403aa
1 #!/usr/bin/perl
3 # Copyright (c) 2003, Pavel Roskin
4 # The Midnight Commander is free software: you can redistribute it
5 # and/or modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation, either version 3 of the License,
7 # or (at your option) any later version.
9 # The Midnight Commander is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Run this script on the map with cross-reference generated by GNU ld,
18 # and it will generate a list of symbols that don't need to be global.
19 # To create the map, run something like this:
20 # make LDFLAGS=-Wl,-Map,output.map,--cref
22 use strict;
24 my %symbols;
25 my %syms;
26 my %objs;
28 if ($#ARGV != 0) {
29 print "Usage: unrefglobals.pl mapfile\n";
30 exit 1;
33 if (!open (MAP, "$ARGV[0]")) {
34 print "Cannot open file \"$ARGV[0]\"\n";
35 exit 1;
38 my $line;
39 my $next_line = <MAP>;
40 while (1) {
41 last unless $next_line;
42 $line = $next_line;
43 $next_line = <MAP>;
44 next unless ($line =~ m{^[A-Za-z_][A-Za-z0-9_]* +[^ /][^ ]+\.o$} or
45 $line =~ m{^[A-Za-z_][A-Za-z0-9_]* +[^ /][^ ]+\.a\([^ ]+\.o\)$});
46 if (!$next_line or ($next_line !~ /^ /)) {
47 my @arr = split (' ', $line);
48 $symbols{$arr[0]} = $arr[1];
49 $syms{$arr[0]} = 1;
50 $objs{$arr[1]} = 1;
54 close(MAP);
56 foreach my $obj (sort keys %objs) {
57 print "$obj\n";
58 foreach my $sym (sort keys %syms) {
59 print "\t$sym\n" if ($symbols{$sym} eq $obj);