--- gcc/fixincludes 2018/04/24 17:52:24 1.1.1.2 +++ gcc/fixincludes 2018/04/24 17:56:29 1.1.1.3 @@ -146,7 +146,7 @@ while [ $# != 0 ]; do /#[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\ + /^#define.NULL[ ]/ i\ #undef NULL ' $2/$file > $2/$file.sed mv $2/$file.sed $2/$file @@ -182,7 +182,7 @@ EOF fi fi -# Fix this Sun file to avoid intefering with stddef.h. +# Fix this Sun file to avoid interfering with stddef.h. file=sys/stdtypes.h if [ -r $file ] && [ ! -r ${LIB}/$file ]; then cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" @@ -227,7 +227,7 @@ EOF fi fi -# Fix this file to avoid intefering with stddef.h. +# Fix this file to avoid interfering with stddef.h. file=sys/types.h if [ -r $file ] && [ ! -r ${LIB}/$file ]; then cp $file ${LIB}/$file >/dev/null 2>&1 || echo "Can't copy $file" @@ -237,7 +237,7 @@ fi if [ -r ${LIB}/$file ]; then echo Fixing $file ex ${LIB}/$file </dev/null 2>&1; then @@ -455,6 +455,10 @@ fi if [ -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 @@ -463,6 +467,26 @@ if [ -r ${LIB}/$file ]; then fi fi +# Fix return type of free and {c,m,re}alloc in 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 on SunOS 4.1. file=locale.h if [ -r $file ] && [ ! -r ${LIB}/$file ]; then @@ -571,6 +595,84 @@ if [ -r ${LIB}/$file ]; then ${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