🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52619

gcc 2.2.2 fixincludes patches for #endif etc

#52619
From: Paul Eggert
Date: Mon, 15 Jun 1992 19:38
741 lines
24484 bytes
Apparently some mailers truncated the fixincludes script that I posted
last week for GCC 2.2.1; several people wrote me asking for the full version.
Here is the same script, updated for GCC 2.2.2.

This script has the following patches to the GCC 2.2.2 fixincludes.
I reported each of these patches one by one for older GCC releases,
but the fixes haven't yet made their way into the official release.

	Non-ANSI lines like `#endif foo' or `#else foo' are fixed.

	You can install the output in a different directory than where
	it is meant to be installed eventually; this helps in certain
	cross-compilation and staging applications.  Specify the eventual
	installation directory in the environment variable DESTLIB.

	The unportable construction `if [ ... ]' is replaced by the
	more portable `if test ...'.

	Spurious `ex' output is removed by replacing commands like
		/size_t/
		i
	by
		/size_t/i

Remove the leading `|' from each line before using the script.

|#! /bin/sh
|# Install modified versions of certain ANSI-incompatible system header files
|# which are fixed to work correctly with ANSI C
|# and placed in a directory that GNU C will search.
|
|# See README-fixinc for more information.
|
|# Directory containing the original header files.
|# (This was named INCLUDES, but that conflicts with a name in Makefile.in.)
|INPUT=${2-${INPUT-/usr/include}}
|
|# This prevents /bin/ex from failing if the current terminal type is
|# unrecognizable.
|TERM=unknown
|export TERM
|
|# Directory in which to store the results; fail if none is specified.
|LIB=${1?}
|
|# Make sure it exists.
|test -d $LIB || mkdir $LIB || exit
|
|# Make LIB absolute.
|cd $LIB && LIB=`pwd` || exit
|
|# Directory where the results will be installed after this script is run.
|DESTLIB=${DESTLIB-$LIB}
|
|echo 'Building fixincludes in ' ${LIB}
|
|# Determine whether this system has symbolic links.
|if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
|  rm -f $LIB/ShouldNotExist
|  LINKS=true
|else
|  LINKS=false
|fi
|
|echo 'Making directories:'
|cd ${INPUT}
|# Find all directories and all symlinks that point to directories.
|files=`	find . -type d -print | sed '/^.$/d'
|	$LINKS && find . -type l -exec test -d '{}' \; -print`
|for file in $files; do
|  rm -rf $LIB/$file
|  test -d $LIB/$file || mkdir $LIB/$file || exit
|done
|
|# treetops gets an alternating list
|# of old directories to copy
|# and the new directories to copy to.
|treetops="${INPUT} ${LIB}"
|
|if $LINKS; then
|  echo 'Making internal symbolic directory links'
|  for file in $files; do
|    dest=`ls -ld $file | sed -n 's/.*-> //p'`
|    case $dest in
|    ?*)
|      cwd=`pwd`
|      # In case $dest is relative, get to $file's dir first.
|      cd ${INPUT}
|      cd `echo ./$file | sed -n 's&[^/]*$&&p'`
|      # Check that the target directory exists.
|      # Redirections changed to avoid bug in sh on Ultrix.
|      (cd $dest) > /dev/null 2>&1
|      case $? in
|      0)
|	cd $dest
|	# X gets the dir that the link actually leads to.
|	x=`pwd`
|	# If link leads back into ${INPUT},
|	# make a similar link here.
|	case $x in
|	${INPUT}/*)
|	  # Y gets the actual target dir name, relative to ${INPUT}.
|	  y=`echo $x | sed -n "s&${INPUT}/&&p"`
|	  echo $file '->' $y ': Making link'
|	  rm -fr ${LIB}/$file > /dev/null 2>&1
|	  ln -s ${DESTLIB}/$y ${LIB}/$file > /dev/null 2>&1
|	  ;;
|	*)
|	  # If the link is to outside ${INPUT},
|	  # treat this directory as if it actually contained the files.
|# This line used to have $dest instead of $x.
|# $dest seemed to be wrong for links found in subdirectories
|# of ${INPUT}.  Does this change break anything?
|	  treetops="$treetops $x ${LIB}/$file"
|	  ;;
|	esac
|      esac
|      cd $cwd
|    esac
|  done
|fi
|
|set x $treetops; shift
|while test $# != 0; do
|  # $1 is an old directory to copy, and $2 is the new directory to copy to.
|  echo "Finding header files in $1:"
|  cd ${INPUT}
|  cd $1
|  files=`find . -name '*.h' -type f -print`
|  echo 'Checking header files:'
|# Note that BSD43_* are used on recent MIPS systems.
|  for file in $files; do
|# This call to egrep is essential, since checking a file with egrep
|# is much faster than actually trying to fix it.
|# It is also essential that most files *not* match!
|# 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.
|#
|# 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
|      echo Fixing $file
|      if test -r $file; then
|	cp $file $2/$file >/dev/null 2>&1	\
|	|| echo "Can't copy $file"
|	chmod +w $2/$file
|	sed -e '
|				   :loop
|	  /\\$/			N
|	  /\\$/			b loop
|	  s%^\([ 	]*#[ 	]*endif[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
|	  s%^\([ 	]*#[ 	]*else[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
|	  /[ 	]_IO[A-Z]*[ 	]*(/	s/(\(.\),/('\''\1'\'',/
|	  /[ 	]BSD43__IO[A-Z]*[ 	]*(/	s/(\(.\),/('\''\1'\'',/
|	  /#define._IO/		s/'\''x'\''/x/g
|	  /#define.BSD43__IO/		s/'\''x'\''/x/g
|	  /[^A-Z]CTRL[ 	]*(/	s/\([^'\'']\))/'\''\1'\'')/
|	  /#define.CTRL/		s/'\''c'\''/c/g
|	  /#define._CTRL/		s/'\''c'\''/c/g
|	  /#define.BSD43_CTRL/		s/'\''c'\''/c/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-zA-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
|	mv $2/$file.sed $2/$file
|	if cmp $file $2/$file >/dev/null 2>&1; then
|	   echo Deleting $2/$file\; no fixes were needed.
|	   rm $2/$file
|	fi
|      fi
|    fi
|  done
|  shift; shift
|done
|
|cd ${INPUT}
|
|# Fix one other error in this file: a mismatched quote not inside a C comment.
|file=sundev/vuid_event.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/sundev || mkdir ${LIB}/sundev || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file comment
|  ex ${LIB}/$file <<EOF
|  g/doesn't/s/doesn't/does not/
|  wq
|EOF
|  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm ${LIB}/$file
|  fi
|fi
|
|# Fix this Sun file to avoid interfering with stddef.h.
|file=sys/stdtypes.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  ex ${LIB}/$file <<EOF
|  /size_t.*;/i
|#ifndef _GCC_SIZE_T
|#define _GCC_SIZE_T
|.
|  /size_t/+1i
|#endif
|.
|  /ptrdiff_t.*;/i
|#ifndef _GCC_PTRDIFF_T
|#define _GCC_PTRDIFF_T
|.
|  /ptrdiff_t/+1i
|#endif
|.
|  /wchar_t.*;/i
|#ifndef _GCC_WCHAR_T
|#define _GCC_WCHAR_T
|.
|  /wchar_t/+1i
|#endif
|.
|  wq
|EOF
|  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm ${LIB}/$file
|  fi
|fi
|
|# Fix this file to avoid interfering with stddef.h.
|file=sys/types.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  ex ${LIB}/$file <<EOF
|  /typedef.*size_t.*;/i
|#ifndef _GCC_SIZE_T
|#define _GCC_SIZE_T
|.
|  /size_t/+1i
|#endif
|.
|  wq
|EOF
|  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm ${LIB}/$file
|  fi
|fi
|
|# Fix an error in this file: a missing semi-colon at the end of the statsswtch
|# structure definition.
|file=rpcsvc/rstat.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/rpcsvc || mkdir ${LIB}/rpcsvc || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file, definition of statsswtch
|  ex ${LIB}/$file <<EOF
|  g/boottime$/s//&;/
|  wq
|EOF
|  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm ${LIB}/$file
|  fi
|fi
|
|# Fix an error in this file: a missing semi-colon at the end of the nodeent
|# structure definition.
|file=netdnet/dnetdb.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/netdnet || mkdir ${LIB}/netdnet || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file, definition of nodeent
|  ex ${LIB}/$file <<EOF
|  g/char.*na_addr *$/s//&;/
|  wq
|EOF
|  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm ${LIB}/$file
|  fi
|fi
|
|# Check for bad #ifdef line (in Ultrix 4.1)
|file=sys/file.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file, bad \#ifdef line
|  ex ${LIB}/$file <<EOF
|  g/^#ifdef KERNEL && !defined/
|  s/#ifdef KERNEL && !defined/#if defined(KERNEL) \&\& !defined/
|  wq
|EOF
|  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm ${LIB}/$file
|  fi
|fi
|
|# Remove nested comments created by endifs in a comment (Ultrix 4.1)
|file=signal.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Check for superfluous `static' (in Ultrix 4.2)
|file=machine/cpu.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/machine || mkdir ${LIB}/machine || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file, superfluous static
|  ex ${LIB}/$file <<EOF
|  g/^static struct tlb_pid_state/
|  s/static//
|  wq
|EOF
|  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm ${LIB}/$file
|  else
|# This file has an alternative name, mips/cpu.h.  Fix that name, too.
|    if cmp machine/cpu.h mips/cpu.h > /dev/null 2>& 1; then
|      test -d ${LIB}/mips || mkdir ${LIB}/mips || exit
|      ln ${LIB}/$file ${LIB}/mips/cpu.h 
|    fi
|  fi
|fi
|
|# Incorrect sprintf declaration in X11/Xmu.h
|file=X11/Xmu.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/X11 || mkdir ${LIB}/X11 || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file sprintf declaration
|  ex ${LIB}/$file <<EOF
|  /^extern char \*	sprintf();$/c
|#ifndef __STDC__
|extern char *	sprintf();
|#endif /* !defined __STDC__ */
|.
|  wq
|EOF
|  if cmp $file ${LIB}/$file >/dev/null 2>&1; then
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm ${LIB}/$file
|  fi
|fi
|
|# Check for missing ';' in struct
|file=netinet/ip.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/netinet || mkdir ${LIB}/netinet || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  sed -e '/^struct/,/^};/s/}$/};/' ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Fix the CAT macro in SunOS memvar.h.
|file=pixrect/memvar.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/pixrect || mkdir ${LIB}/pixrect || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  sed -e '/^#define.CAT(a,b)/ i\
|#ifdef __STDC__ \
|#define CAT(a,b) a##b\
|#else
|/^#define.CAT(a,b)/ a\
|#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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Check for yet more missing ';' in struct (in SunOS 4.0.x)
|file=rpcsvc/rusers.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/rpcsvc || mkdir ${LIB}/rpcsvc || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  sed -e '/^struct/,/^};/s/_cnt$/_cnt;/' ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Fix return type of abort, exit, free, *alloc in <stdlib.h> on SunOS 4.1.
|file=stdlib.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  sed -e 's/int	abort/void	abort/g' \
|  -e 's/int	free/void	free/g' \
|  -e 's/char \*	calloc/void \*	calloc/g' \
|  -e 's/char \*	malloc/void \*	malloc/g' \
|  -e 's/char \*	realloc/void \*	realloc/g' \
|  -e 's/int	exit/void	exit/g' ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
|file=malloc.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
|fi
|
|if [ -r ${LIB}/$file ]; then
|  echo Fixing $file
|  sed -e 's/typedef[ 	]char \*	malloc_t/typedef void \*	malloc_t/g' \
|  -e 's/int[ 	][ 	]*free/void	free/g' \
|  ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|
|# Fix bogus comment in <locale.h> on SunOS 4.1.
|file=locale.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  sed -e 's%#endif / \*%#endif /\* %g' ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Fix bogus #ifdef in <hsfs/hsfs_spec.h> on SunOS 4.1.
|file=hsfs/hsfs_spec.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/hsfs || mkdir ${LIB}/hsfs || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
|    ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Fix bogus #ifdef in <hsfs/hsnode.h> on SunOS 4.1.
|file=hsfs/hsnode.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/hsfs || mkdir ${LIB}/hsfs || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  sed -e 's/\#ifdef __i386__ || __sun4c__/\#if __i386__ || __sun4c__/g' \
|    ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Fix bogus #ifdef in <hsfs/iso_spec.h> on SunOS 4.1.
|file=hsfs/iso_spec.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/hsfs || mkdir ${LIB}/hsfs || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file
|  sed -e 's/\#ifdef __i386__ || __vax__/\#if __i386__ || __vax__/g' \
|    ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Incorrect #include in Sony News-OS 3.2.
|file=machine/machparam.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/machine || mkdir ${LIB}/machine || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file, incorrect \#include
|  sed -e 's@"../machine/endian.h"@<machine/endian.h>@' \
|    ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Multiline comment after typedef on IRIX 4.0.1.
|file=sys/types.h
|if test -r $file && test ! -r ${LIB}/$file; then
|  test -d ${LIB}/sys || mkdir ${LIB}/sys || exit
|  cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file"
|  chmod +w ${LIB}/$file 2>/dev/null
|fi
|
|if test -r ${LIB}/$file; then
|  echo Fixing $file, comment in the middle of \#ifdef
|  sed -e 's@type of the result@type of the result */@' \
|    -e 's@of the sizeof@/* of the sizeof@' \
|    ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
|# declaration on Sun OS 4.x.  We must only fix this on Sun OS 4.x, because
|# many other systems have similar text but correct versions of the file.
|# To ensure only Sun's is fixed, we grep for a likely unique string.
|file=memory.h
|if egrep '/\*	@\(#\)memory.h 1.4 88/08/19 SMI; from S5R2 1.2	\*/' $file > /dev/null; then
|  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
|  fi
|  if [ -r ${LIB}/$file ]; then
|    echo Replacing $file
|    cat > ${LIB}/$file << EOF
|/* This file was generated by fixincludes */
|#ifndef __memory_h__
|#define __memory_h__
|
|#ifdef __STDC__
|extern void *memccpy();
|extern void *memchr();
|extern void *memcpy();
|extern void *memset();
|#else
|extern char *memccpy();
|extern char *memchr();
|extern char *memcpy();
|extern char *memset();
|#endif /* __STDC__ */
|
|extern int memcmp();
|
|#endif __memory_h__
|EOF
|  fi
|fi
|
|# parameters not const on DECstation Ultrix V4.0.
|file=stdio.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
|fi
|
|if [ -r ${LIB}/$file ]; then
|  echo Fixing $file, non-const arg
|  sed -e 's@perror( char \*__s );@perror( const char *__s );@' \
|      -e 's@fputs( char \*__s,@fputs( const char *__s,@' \
|      -e 's@fopen( char \*__filename, char \*__type );@fopen( const char *__filename, const char *__type );@' \
|      -e 's@fwrite( void \*__ptr,@fwrite( const void *__ptr,@' \
|      -e 's@fscanf( FILE \*__stream, char \*__format,@fscanf( FILE *__stream, const char *__format,@' \
|      -e 's@scanf( char \*__format,@scanf( const char *__format,@' \
|      -e 's@sscanf( char \*__s, char \*__format,@sscanf( const char *__s, const char *__format,@' \
|    ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|# parameter to atof not const on DECstation Ultrix V4.0.
|file=math.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
|fi
|
|if [ -r ${LIB}/$file ]; then
|  echo Fixing $file, non-const arg
|  sed -e 's@atof( char \*__nptr );@atof( const char *__nptr );@' \
|    ${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
|    echo Deleting ${LIB}/$file\; no fixes were needed.
|    rm -f ${LIB}/$file
|  fi
|fi
|
|echo 'Removing unneeded directories:'
|cd $LIB
|files=`find . -type d -print | sort -r`
|for file in $files; do
|  rmdir $LIB/$file > /dev/null 2>&1
|done
|
|if $LINKS; then
|  echo 'Making internal symbolic non-directory links'
|  cd ${INPUT}
|  files=`find . -type l -print`
|  for file in $files; do
|    dest=`ls -ld $file | sed -n 's/.*-> //p'`
|    case $dest in
|    /*) ;;
|    *)
|      target=${LIB}/`echo file | sed "s|[^/]*\$|$dest|"`
|      if test -f $target; then
|        ln -s $dest ${LIB}/$file >/dev/null 2>&1
|      fi
|    esac
|  done
|fi
|
|exit 0
Technical Details
Message-ID: <bi1Th}7D@twinsun.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!ames!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,d7bd420caa731646,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-06-15 08:26:18 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!ames!elroy.jpl.nasa.gov!ucla-cs!twinsun!eggert
From: eggert@twinsun.com (Paul Eggert)
Subject: gcc 2.2.2 fixincludes patches for #endif etc
Message-ID: <bi1Th}7D@twinsun.com>
Sender: usenet@twinsun.com
Nntp-Posting-Host: twinsun
Organization: Twin Sun, Inc
Date: Mon, 15 Jun 1992 19:38:46 GMT
Lines: 741