Article View: gnu.gcc.bug
Article #1445Fixing include files so that -ansi and -Wall co-exist better
From: Phillip Musumeci
Date: Sat, 21 Nov 1992 16:57
Date: Sat, 21 Nov 1992 16:57
93 lines
3558 bytes
3558 bytes
Hi,
I installed gcc-2.3.1 (sunos-4.1.2) and we've had almost no problems.
However, the fixincludes script doesn't remove UNcommented text which
follows #endif statements (in fact, there is an instance of
#endif __memory_h__
being added to the sunos-4.1.2 fixed file memory.h). These pieces of
UNcommented text really help the human but don't seem to get on well with
the compiler in ansi/Wall mode. I have written the following two bash shell
scripts to go through the include files and just ditch any comments
trailing #endif statements [I assume that there is only ever one #endif per
line]. These scripts might be useful to someone.
phillip
===========================================================================
SCRIPT 1
#!/usr/gnu/bin/bash
#
# "gcc -Wall" requires only commented text to follow an #endif statement.
#
# This script searches down through the fixed include files and
# 1) searches for files with uncommented strings following #endif statements
# 2) cuts any text following **each** #endif in that file, and
# 3) keeps an original file with extension .ORIG if changes were required.
#
# I took the endif-comment-stripping code for ultrix in gcc-2.3.1's
# fixincludes as the basis of this additional correction stage.
# A better fix would be to comment out any uncommented text.
#
# phillip@ee.adfa.oz.au 19-nov-92
# define the top of your include files
GTOP=/usr/gnu2/lib/gcc-lib/sparc/2.3.1
files=
for x in `find $GTOP/include -name "*.h" -print ` ; do
y="`cat $x | grep \#endif | \
sed -e 's/#endif//g' | \
sed -e 's/\/\*[^*/]*\*\///g' `"
z="`echo $y`" # remove empty lines
if [ "$z" ] ; then
files="$files $x"
fi
done
# Remove any junk trailing #endif
#
if [ "$files" ] ; then
echo "Fixing text which is not ansi-compatible following #endif ..."
for file in $files ; do
cp -p $file $file.ORIG # ***OVERWRITE*** any existing .ORIG file
echo Fixing $file
sed -e 's/#endif.*/#endif/' $file > ${file}.sed
rm -f $file; mv ${file}.sed $file
if cmp $file $file.ORIG >/dev/null 2>&1; then
echo Restoring $file\; no fixes were needed.
rm -f $file
mv ${file}.ORIG $file
fi
done
fi
exit
===========================================================================
SCRIPT 2
#!/usr/gnu/bin/bash
# This script searches down through the refixed include files and
# produces a diff of those modified. phillip@ee.adfa.oz.au 19-nov-92
# define the top of your include files
GTOP=/usr/gnu2/lib/gcc-lib/sparc/2.3.1
delimit="-------------------------------------------------"
for x in `find $GTOP/include -name "*.ORIG" -print ` ; do
fn="`echo \"$x\" | sed -e \"s:.ORIG::g\"`" # get .h file's name
echo "${fn} ${delimit}${delimit}" | \
sed -e "s:$GTOP/include/: :g" | cut -c1-75 # print out delimiter
diff ${fn}.ORIG ${fn} # display difference
done | more
exit
===========================================================================
END OF SHELL SCRIPTS
Technical Details
Message-ID:
<9211210057.AA03287@mirriwinni.ee.adfa.oz.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!mirriwinni.ee.adfa.oz.au!phillipShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!mirriwinni.ee.adfa.oz.au!phillip From: phillip@mirriwinni.ee.adfa.oz.au (Phillip Musumeci) Subject: Fixing include files so that -ansi and -Wall co-exist better Message-ID: <9211210057.AA03287@mirriwinni.ee.adfa.oz.au> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Sat, 21 Nov 1992 16:57:47 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 96