1 eval '(exit $?0)' && eval 'exec perl -w -S $0 ${1+"$@"}'
2 & eval 'exec perl -w -S $0 $argv:q'
5 # ************************************************************
6 # Description : Find macros in specified config files that
7 # are not referenced in other config files,
8 # but are referenced in the rest of the source
10 # Author : Chad Elliott
11 # Create Date : 12/22/2004
12 # ************************************************************
14 # ************************************************************
16 # ************************************************************
23 # ************************************************************
25 # ************************************************************
27 my($in_comment) = undef;
29 # ************************************************************
31 # ************************************************************
35 my($line) = $fh->getline();
38 ## Remove the line feed
41 ## Remove one line c comments
42 $line =~ s/\/\*.*\*\///;
44 ## Check for multi lined c comments
45 if ($line =~ s/\/\*.*//) {
48 elsif ($line =~ s/.*\*\///) {
55 ## Remove c++ comments
59 if ($line =~ s/\\\s*$//) {
60 $line .= getline
($fh);
73 foreach my $file (@files) {
74 my($fh) = new FileHandle
();
76 if (open($fh, $file)) {
78 while(defined($_ = getline
($fh))) {
79 if (($defines & 1) == 1 && /^\s*#\s*define\s*([^\s]+)/) {
82 if (!defined $$macros{$word}) {
83 $$macros{$word} = $file;
86 elsif (($defines & 2) == 2 && /^\s*#\s*if/) {
87 foreach my $word (split(/[^\w]/, $_)) {
88 if ($word =~ /^[^\d]\w+$/ &&
89 $word !~ /^if([n]?def)?$/ &&
90 $word !~ /^define[d]?/ &&
91 $word !~ /^els(e|if)$/ && !defined $$macros{$word}) {
92 $$macros{$word} = $file;
101 print STDERR
"Unable to open $file\n";
112 print STDERR
"ERROR: $msg\n";
115 print STDERR
'Usage: ', basename
($0), " [-I <directory>] <config headers>\n\n",
116 "This script will provide a set of macros that may possibly\n",
117 "be removed from ACE.\n\n",
118 "It should be run under ACE_wrappers/ace and the input should\n",
119 "be the config header file or files planned for removal.\n";
124 # ************************************************************
126 # ************************************************************
129 my(@dirs) = ('.', 'os_include', 'os_include/sys',
130 'os_include/netinet', 'os_include/net',
134 for(my $i = 0; $i <= $#ARGV; ++$i) {
135 my($arg) = $ARGV[$i];
140 elsif ($arg eq '-I') {
142 if (defined $ARGV[$i]) {
143 push(@dirs, $ARGV[$i]);
146 usageAndExit
('-I requires a directory parameter');
150 usageAndExit
("$arg is an unknown option");
158 if (!defined $files[0]) {
162 ## First find all of the control macros
164 findMacros
(3, \
%control, @files);
166 ## Now find all of the macros from the other config files
167 my(@other) = grep(!/config-all\.h|config-lite\.h/, <config
-*.h
>);
169 for(my $i = 0; $i <= $#other; ++$i) {
170 foreach my $file (@files) {
171 if ($other[$i] eq $file) {
172 splice(@other, $i, 1);
179 findMacros
(3, \
%other, @other);
182 my(%notreferenced) = ();
183 foreach my $macro (keys %control) {
184 if (!defined $other{$macro}) {
185 $notreferenced{$macro} = $control{$macro};
190 ## Find all other macros
192 foreach my $dir (@dirs) {
193 my($orig) = getcwd
();
195 my(@more) = <*.h
*.i
* *.cpp
>;
197 foreach my $file (@more) {
198 $file = "$dir/$file";
206 for(my $i = 0; $i <= $#all; ++$i) {
207 foreach my $file (@files, @other) {
208 if ($all[$i] eq $file) {
217 findMacros
(2, \
%all, @all);
219 foreach my $macro (sort keys %notreferenced) {
220 if (defined $all{$macro}) {