Pristine Ack-5.5
[Ack-5.5.git] / bin / do_resolve
1 : '$Id: do_resolve,v 1.2 1994/06/23 13:46:48 ceriel Exp $'
2
3 : Resolve name clashes in the files on the argument list. If these
4 : files reside in another directory, a copy is made in the current
5 : directory. If not, it is overwritten. Never do this in a source
6 : directory! A list of the new files is produced on standard output.
7
8 UTIL_BIN=$UTIL_HOME/bin
9
10 trap "rm -f tmp$$ a.out nmclash.* longnames clashes" 0 1 2 3 15
11
12 : first find out if we have to resolve problems with identifier significance.
13
14 cat > nmclash.c <<'EOF'
15 /* Accepted if many characters of long names are significant */
16 abcdefghijklmnopr() { }
17 abcdefghijklmnopq() { }
18 main() { }
19 EOF
20 if $CC nmclash.c
21 then    : no identifier significance problem
22         for i in $*
23         do
24                 echo $i
25         done
26 else
27         $UTIL_BIN/prid -l7 $* > longnames
28
29         : remove code generating routines from the clashes list.
30         : code generating routine names start with C_.
31         : also remove names starting with flt_.
32
33         sed '/^C_/d' < longnames | sed '/^flt_/d' > tmp$$
34         $UTIL_BIN/cclash -c -l7 tmp$$ > clashes
35         for i in $*
36         do
37                 $UTIL_BIN/cid -Fclashes < $i > tmp$$
38                 n=`basename $i .xxx`
39                 if cmp -s $n tmp$$
40                 then
41                         rm -f tmp$$
42                 else
43                         mv tmp$$ $n
44                 fi
45                 echo $n
46         done
47 fi