do_resolve 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. : '$Id$'
  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. UTIL_BIN=$UTIL_HOME/bin
  8. trap "rm -f tmp$$ a.out nmclash.* longnames clashes" 0 1 2 3 15
  9. : first find out if we have to resolve problems with identifier significance.
  10. cat > nmclash.c <<'EOF'
  11. /* Accepted if many characters of long names are significant */
  12. abcdefghijklmnopr() { }
  13. abcdefghijklmnopq() { }
  14. main() { }
  15. EOF
  16. if $CC nmclash.c
  17. then : no identifier significance problem
  18. for i in $*
  19. do
  20. echo $i
  21. done
  22. else
  23. $UTIL_BIN/prid -l7 $* > longnames
  24. : remove code generating routines from the clashes list.
  25. : code generating routine names start with C_.
  26. : also remove names starting with flt_.
  27. sed '/^C_/d' < longnames | sed '/^flt_/d' > tmp$$
  28. $UTIL_BIN/cclash -c -l7 tmp$$ > clashes
  29. for i in $*
  30. do
  31. $UTIL_BIN/cid -Fclashes < $i > tmp$$
  32. n=`basename $i .xxx`
  33. if cmp -s $n tmp$$
  34. then
  35. rm -f tmp$$
  36. else
  37. mv tmp$$ $n
  38. fi
  39. echo $n
  40. done
  41. fi