Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Phillip Musumeci
Sat, 21 Nov 1992 16:57
Fixing include files so that -ansi and -Wall co-exist better
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads