From: Ian Lance Taylor Date: Mon, 22 Mar 1993 23:30:13 +0000 (+0000) Subject: Fix #endif foo; don't alter sh options; clean up all DONE files X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=25e51a6947c6efd9ee1424f69d4a1c338ecaf5a1;p=gcc.git Fix #endif foo; don't alter sh options; clean up all DONE files From-SVN: r3832 --- diff --git a/gcc/fixincludes b/gcc/fixincludes index cd675a3c110..87f0d610dba 100755 --- a/gcc/fixincludes +++ b/gcc/fixincludes @@ -211,7 +211,8 @@ if $LINKS; then done fi -set - $treetops +set x $treetops +shift while [ $# != 0 ]; do # $1 is an old directory to copy, and $2 is the new directory to copy to. cd ${INPUT} @@ -241,41 +242,62 @@ while [ $# != 0 ]; do # Thus, matching every #endif is unacceptable. # But the argument to egrep must be kept small, or many versions of egrep # won't be able to handle it. -# rms: I removed `|#[el].*if.*[^/ ]' because it made egrep fail. - if egrep '//|[ _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|sparc|vax|sun|pyr)' $file > /dev/null; then +# +# We use the pattern [!-.0-~] instead of [^/ ] to match a noncomment +# following #else or #endif because some buggy egreps think [^/] matches +# newline, and they thus think `#else ' matches `#e[ndiflse]*[ ]+[^/ ]'. +# +# We use the pattern [^a-zA-Z0-9_][_a-ce-km-z][a-z0-9] to match an identifier +# following #if or #elif that is not surrounded by __. The `a-ce-km-z' +# in this pattern lacks `d' and `l'; this means we don't worry about +# identifiers starting with `d' or `l'. This is OK, since none of the +# identifiers below start with `d' or `l'. It also greatly improves +# performance, since many files contain lines of the form `#if ... defined ...' +# or `#if lint'. + if egrep '//|[ _]_IO|CTRL|^#define.NULL|^#e[nl][ds][ief]*[ ]+[!-.0-~]|^#[el]*if.*[^a-zA-Z0-9_][_a-ce-km-z][a-z0-9]' $file >/dev/null; then if [ -r $file ]; then cp $file $2/$file >/dev/null 2>&1 \ || echo "Can't copy $file" chmod +w $2/$file chmod a+r $2/$file -# Following two lines removed. -# s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */% -# s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */% - sed -e ' :loop /\\$/ N /\\$/ b loop + s%^\([ ]*#[ ]*endif[ ]*\)\([^/ ].*\)$%\1/* \2 */% + s%^\([ ]*#[ ]*else[ ]*\)\([^/ ].*\)$%\1/* \2 */% /\/\/[^*]/ s|//\(.*\)$|/*\1*/| /[ ]_IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/ /[ ]BSD43__IO[A-Z]*[ ]*(/ s/(\(.\),/('\''\1'\'',/ /#define._IO/ s/'\''\([cgx]\)'\''/\1/g - /#define.BSD43__IO/ s/'\''\(]cgx]\)'\''/\1/g + /#define.BSD43__IO/ s/'\''\([cgx]\)'\''/\1/g /[^A-Z]CTRL[ ]*(/ s/\([^'\'']\))/'\''\1'\'')/ /#define.CTRL/ s/'\''\([cgx]\)'\''/\1/g /#define._CTRL/ s/'\''\([cgx]\)'\''/\1/g /#define.BSD43_CTRL/ s/'\''\([cgx]\)'\''/\1/g - /#[a-z]*if.*[ (]m68k/ s/\([^_]\)m68k/\1__m68k__/g - /#[a-z]*if.*[ (]__i386/ s/__i386/__i386__/g - /#[a-z]*if.*[ (]i386/ s/\([^_]\)i386/\1__i386__/g - /#[a-z]*if.*[ (]sparc/ s/\([^_]\)sparc/\1__sparc__/g - /#[a-z]*if.*[ (]mc68000/ s/\([^_]\)mc68000/\1__mc68000__/g - /#[a-z]*if.*[ (]vax/ s/\([^_]\)vax/\1__vax__/g - /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)\([^a-z0-9_]\)/\1__\2__\3/g - /#[a-z]*if.*[ (]sun/ s/\([^_]\)\(sun[a-z0-9]*\)$/\1__\2__/g - /#[a-z]*if.*[ (]ns32000/ s/\([^_]\)ns32000/\1__ns32000__/g - /#[a-z]*if.*[ (]pyr/ s/\([^_]\)pyr/\1__pyr__/g - /#[a-z]*if.*[ (]is68k/ s/\([^_]\)is68k/\1__is68k__/g + /#[el]*if/{ + # Surround each word with spaces, to simplify matching below. + s/[a-zA-Z0-9_][a-zA-Z0-9_]*/ & /g + + # ANSIfy each pre-ANSI machine-dependent symbol + # by surrounding it with __ __. + s/ bsd4\([0-9]\) / __bsd4\1__ /g + s/ _*i386 / __i386__ /g + s/ is68k / __is68k__ /g + s/ m68k / __m68k__ /g + s/ mc680\([0-9]\)0 / __mc680\10__ /g + s/ news\([0-9]*\) / __news\1__ /g + s/ ns32000 / __ns32000__ /g + s/ pyr / __pyr__ /g + s/ sony_news / __sony_news__ /g + s/ sparc / __sparc__ /g + s/ sun\([a-z0-9]*\) / __sun\1__ /g + s/ unix / __unix__ /g + s/ vax / __vax__ /g + + # Remove the spaces that we inserted around each word. + s/ \([a-zA-Z0-9_][a-zA-Z0-9_]*\) /\1/g + } /^#define.NULL[ ]/ i\ #undef NULL ' $2/$file > $2/$file.sed @@ -497,21 +519,21 @@ fi # Remove nested comments created by #endifs in a comment (Ultrix 4.1) # Only needed if commenting out junk after #endif. -#file=signal.h -#if [ -r $file ] && [ ! -r ${LIB}/$file ]; then -# cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" -# chmod +w ${LIB}/$file 2>/dev/null -# chmod a+r ${LIB}/$file 2>/dev/null -#fi -# -#if [ -r ${LIB}/$file ]; then -# echo Fixing $file, nested comments -# sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed -# rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file -# if cmp $file ${LIB}/$file >/dev/null 2>&1; then -# rm -f ${LIB}/$file -# fi -#fi +file=signal.h +if [ -r $file ] && [ ! -r ${LIB}/$file ]; then + cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" + chmod +w ${LIB}/$file 2>/dev/null + chmod a+r ${LIB}/$file 2>/dev/null +fi + +if [ -r ${LIB}/$file ]; then + echo Fixing $file, nested comments + sed -e 's/#endif.*/#endif/' ${LIB}/$file > ${LIB}/${file}.sed + rm -f ${LIB}/$file; mv ${LIB}/${file}.sed ${LIB}/$file + if cmp $file ${LIB}/$file >/dev/null 2>&1; then + rm -f ${LIB}/$file + fi +fi # Check for superfluous `static' (in Ultrix 4.2) file=machine/cpu.h @@ -1010,7 +1032,8 @@ if $LINKS; then done fi -# Prevent premature exit when subsequently processing OTHER_FIXINCLUDES_DIRS. -rm ${LIB}/DONE +echo 'Cleaning up DONE files.' +cd $LIB +find . -name DONE -exec rm -f {} ';' exit 0