]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/fixincludes
*** empty log message ***
[gcc.git] / gcc / fixincludes
index aab3ee1af5ccdf4a0bdf93138bb804f85041e006..006858391fc9008c64a68ca20b490d86b4efb01c 100755 (executable)
@@ -43,11 +43,9 @@ fi
 
 echo 'Making directories:'
 cd ${INPUT}
-if $LINKS; then
-  files=`ls -LR | sed -n s/:$//p`
-else
-  files=`find . -type d -print | sed '/^.$/d'`
-fi
+# 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
   if [ ! -d $LIB/$file ]
@@ -110,20 +108,25 @@ while [ $# != 0 ]; do
   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.
-    if egrep '[        _]_IO|CTRL|#define.NULL|#[el]*if.*([0-9]|#e[nl]|sparc|vax|sun|pyr)' $file > /dev/null; then
+# 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%\(#[        ]*endif[        ]*\)\([^/       ].*\)$%\1/* \2 */%
-         s%\(#[        ]*else[         ]*\)\([^/       ].*\)$%\1/* \2 */%
          /[    ]_IO[A-Z]*[     ]*(/    s/(\(.\),/('\''\1'\'',/
          /[    ]BSD43__IO[A-Z]*[       ]*(/    s/(\(.\),/('\''\1'\'',/
          /#define._IO/         s/'\''x'\''/x/g
@@ -179,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"
@@ -191,8 +194,8 @@ if [ -r ${LIB}/$file ]; then
   ex ${LIB}/$file <<EOF
   /size_t.*;/
   i
-#ifndef _SIZE_T
-#define _SIZE_T
+#ifndef _GCC_SIZE_T
+#define _GCC_SIZE_T
 .
   /size_t/+1
   i
@@ -200,8 +203,8 @@ if [ -r ${LIB}/$file ]; then
 .
   /ptrdiff_t.*;/
   i
-#ifndef _PTRDIFF_T
-#define _PTRDIFF_T
+#ifndef _GCC_PTRDIFF_T
+#define _GCC_PTRDIFF_T
 .
   /ptrdiff_t/+1
   i
@@ -209,8 +212,8 @@ if [ -r ${LIB}/$file ]; then
 .
   /wchar_t.*;/
   i
-#ifndef _WCHAR_T
-#define _WCHAR_T
+#ifndef _GCC_WCHAR_T
+#define _GCC_WCHAR_T
 .
   /wchar_t/+1
   i
@@ -224,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"
@@ -236,8 +239,8 @@ if [ -r ${LIB}/$file ]; then
   ex ${LIB}/$file <<EOF
   /size_t.*;/
   i
-#ifndef _SIZE_T
-#define _SIZE_T
+#ifndef _GCC_SIZE_T
+#define _GCC_SIZE_T
 .
   /size_t/+1
   i
@@ -313,6 +316,24 @@ EOF
   fi
 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
+#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
 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
@@ -340,7 +361,7 @@ EOF
   fi
 fi
 
-# Deal with yet another challenge, this in X11/Xmu.h
+# Incorrect sprintf declaration in X11/Xmu.h
 file=X11/Xmu.h
 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
   mkdir ${LIB}/X11 2>/dev/null
@@ -382,7 +403,7 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
-# Fix the CAT macro in memvar.h.
+# Fix the CAT macro in SunOS memvar.h.
 file=pixrect/memvar.h
 if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
   mkdir ${LIB}/pixrect 2>/dev/null
@@ -434,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
@@ -516,6 +541,45 @@ if [ -r ${LIB}/$file ]; then
   fi
 fi
 
+# Incorrect #include in Sony News-OS 3.2.
+file=machine/machparam.h
+if [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  mkdir ${LIB}/machine 2>/dev/null
+  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, 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 [ -r $file ] && [ ! -r ${LIB}/$file ]; then
+  mkdir ${LIB}/sys 2>/dev/null
+  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, 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
+
 echo 'Removing unneeded directories:'
 cd $LIB
 files=`find . -type d -print | sort -r`
This page took 0.037693 seconds and 5 git commands to generate.