🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Tue, 03 Nov 1992 04:33
three fixincludes patches (GCC 2.3.1, SunOS 4.1.2)
#57
Author: Paul Eggert
Date: Tue, 03 Nov 1992 04:33
229 lines
8842 bytes
Here are some changes for GCC 2.3.1's fixincludes to handle the following
problems.

1.  You can't run fixincludes into a staging area; i.e. you can't move the
output of fixincludes after building the output.

2.  fixincludes leaves behind DONE files in its output area.

3.  fixincludes doesn't fix constructions like `#endif foo', which are common
in SunOS 4.x include files, and which generate many warnings with gcc -W.

Here is a patch.  The first three hunks of this patch fix (1) by allowing the
user to specify DESTLIB, an environment variable which specifies the eventual
place where the output will be moved to.  The last hunk of this patch fixes
(2).  The rest of this patch fixes (3).


===================================================================
RCS file: fixincludes,v
retrieving revision 2.3
retrieving revision 2.3.1.2
diff -c -r2.3 -r2.3.1.2
*** fixincludes	1992/10/20 01:20:47	2.3
--- fixincludes	1992/11/03 03:44:09	2.3.1.2
***************
*** 40,45 ****
--- 40,48 ----
  exit 1
  fi
  
+ # Directory where the results will be installed after this script is run.
+ DESTLIB=${DESTLIB-$LIB}
+ 
  echo Building fixed headers in ${LIB}
  
  # Determine whether this system has symbolic links.
***************
*** 143,149 ****
  	  y=`echo $x | sed -n "s&${INPUT}/&&p"`
  	  echo $file '->' $y ': Making link'
  	  rm -fr ${LIB}/$file > /dev/null 2>&1
! 	  ln -s ${LIB}/$y ${LIB}/$file > /dev/null 2>&1
  	else
  	  # If the link is to a dir $target outside ${INPUT},
  	  # repoint the link at ${INPUT}/root$target
--- 146,152 ----
  	  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
  	else
  	  # If the link is to a dir $target outside ${INPUT},
  	  # repoint the link at ${INPUT}/root$target
***************
*** 165,171 ****
  	    done
  	  fi
  	  rm -fr ${LIB}/$file > /dev/null 2>&1
! 	  ln -s ${LIB}/root$x ${LIB}/$file > /dev/null 2>&1
  	  treetops="$treetops $x ${LIB}/root$x"
  	fi
        fi
--- 168,174 ----
  	    done
  	  fi
  	  rm -fr ${LIB}/$file > /dev/null 2>&1
! 	  ln -s ${DESTLIB}/root$x ${LIB}/$file > /dev/null 2>&1
  	  treetops="$treetops $x ${LIB}/root$x"
  	fi
        fi
***************
*** 204,224 ****
  # 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
        echo Fixing $file
        if [ -r $file ]; then
  	cp $file $2/$file >/dev/null 2>&1	\
  	|| echo "Can't copy $file"
  	chmod +w $2/$file
- # Following two lines removed.
- #	  s%^\([ 	]*#[ 	]*endif[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
- #	  s%^\([ 	]*#[ 	]*else[ 	]*\)\([^/ 	].*\)$%\1/* \2 */%
- 
  	sed -e '
  				   :loop
  	  /\\$/			N
  	  /\\$/			b loop
  	  /\/\//			s|//\(.*\)$|/*\1*/|
  	  /[ 	]_IO[A-Z]*[ 	]*(/	s/(\(.\),/('\''\1'\'',/
  	  /[ 	]BSD43__IO[A-Z]*[ 	]*(/	s/(\(.\),/('\''\1'\'',/
--- 207,236 ----
  # 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 [ -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 */%
  	  /\/\//			s|//\(.*\)$|/*\1*/|
  	  /[ 	]_IO[A-Z]*[ 	]*(/	s/(\(.\),/('\''\1'\'',/
  	  /[ 	]BSD43__IO[A-Z]*[ 	]*(/	s/(\(.\),/('\''\1'\'',/
***************
*** 228,244 ****
  	  /#define.CTRL/		s/'\''c'\''/c/g
  	  /#define._CTRL/		s/'\''c'\''/c/g
  	  /#define.BSD43_CTRL/		s/'\''c'\''/c/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
  	  /^#define.NULL[ 	]/	i\
  		#undef NULL
  	' $2/$file > $2/$file.sed
--- 240,268 ----
  	  /#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-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
***************
*** 411,431 ****
  
  # 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
! #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
! #    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
--- 435,455 ----
  
  # 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
! 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
!     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
***************
*** 867,870 ****
--- 891,898 ----
    done
  fi
  
+ echo 'Cleaning up DONE files.'
+ cd $LIB
+ find . -name DONE -exec rm -f {} ';'
+ 
  exit 0
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