home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / gcc / bug / 2808 < prev    next >
Encoding:
Text File  |  1992-11-20  |  3.4 KB  |  109 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!mirriwinni.ee.adfa.oz.au!phillip
  3. From: phillip@mirriwinni.ee.adfa.oz.au (Phillip Musumeci)
  4. Subject: Fixing include files so that -ansi and -Wall co-exist better
  5. Message-ID: <9211210057.AA03287@mirriwinni.ee.adfa.oz.au>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Sat, 21 Nov 1992 16:57:47 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 96
  12.  
  13. Hi,
  14.    I installed gcc-2.3.1 (sunos-4.1.2) and we've had almost no problems.
  15. However, the fixincludes script doesn't remove UNcommented text which
  16. follows #endif statements (in fact, there is an instance of
  17.  
  18. #endif __memory_h__
  19.  
  20. being added to the sunos-4.1.2 fixed file memory.h). These pieces of
  21. UNcommented text really help the human but don't seem to get on well with
  22. the compiler in ansi/Wall mode. I have written the following two bash shell
  23. scripts to go through the include files and just ditch any comments
  24. trailing #endif statements [I assume that there is only ever one #endif per
  25. line]. These scripts might be useful to someone.
  26.  
  27. phillip
  28.  
  29. ===========================================================================
  30. SCRIPT 1
  31.  
  32. #!/usr/gnu/bin/bash
  33. #
  34. # "gcc -Wall" requires only commented text to follow an #endif statement.
  35. #
  36. # This script searches down through the fixed include files and
  37. #  1) searches for files with uncommented strings following #endif statements
  38. #  2) cuts any text following **each** #endif in that file, and
  39. #  3) keeps an original file with extension .ORIG if changes were required.
  40. #
  41. # I took the endif-comment-stripping code for ultrix in gcc-2.3.1's
  42. # fixincludes as the basis of this additional correction stage.
  43. # A better fix would be to comment out any uncommented text.
  44. #
  45. # phillip@ee.adfa.oz.au  19-nov-92
  46.  
  47. # define the top of your include files
  48. GTOP=/usr/gnu2/lib/gcc-lib/sparc/2.3.1
  49.  
  50. files=
  51. for x in `find $GTOP/include -name "*.h" -print ` ; do
  52.   y="`cat $x | grep \#endif | \
  53.       sed -e 's/#endif//g' | \
  54.       sed -e 's/\/\*[^*/]*\*\///g' `"
  55.   z="`echo $y`"            # remove empty lines
  56.   if [ "$z" ] ; then
  57.     files="$files $x"
  58.   fi
  59. done
  60.  
  61. # Remove any junk trailing #endif
  62. #
  63. if [ "$files" ] ; then
  64.   echo "Fixing text which is not ansi-compatible following #endif ..."
  65.   for file in $files ; do
  66.  
  67.   cp -p $file $file.ORIG        # ***OVERWRITE*** any existing .ORIG file
  68.   echo Fixing $file
  69.  
  70.   sed -e 's/#endif.*/#endif/' $file > ${file}.sed
  71.   rm -f $file; mv ${file}.sed $file
  72.   if cmp $file $file.ORIG >/dev/null 2>&1; then
  73.     echo Restoring $file\; no fixes were needed.
  74.     rm -f $file
  75.     mv ${file}.ORIG $file
  76.   fi
  77.  
  78.   done
  79.  
  80. fi
  81. exit
  82.  
  83. ===========================================================================
  84. SCRIPT 2
  85.  
  86. #!/usr/gnu/bin/bash
  87. # This script searches down through the refixed include files and
  88. # produces a diff of those modified.        phillip@ee.adfa.oz.au  19-nov-92
  89.  
  90. # define the top of your include files
  91. GTOP=/usr/gnu2/lib/gcc-lib/sparc/2.3.1
  92.  
  93. delimit="-------------------------------------------------"
  94.  
  95. for x in `find $GTOP/include -name "*.ORIG" -print ` ; do
  96.   fn="`echo \"$x\" | sed -e \"s:.ORIG::g\"`"          # get .h file's name
  97.   echo "${fn} ${delimit}${delimit}" | \
  98.     sed -e "s:$GTOP/include/: :g" | cut -c1-75        # print out delimiter
  99.   diff ${fn}.ORIG ${fn}                               # display difference
  100. done | more
  101.  
  102. exit
  103.  
  104. ===========================================================================
  105. END OF SHELL SCRIPTS
  106.  
  107.  
  108.  
  109.