]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/fixproto
Append "#include <stdlib.h>" to assert.h if it uses exit or abort.
[gcc.git] / gcc / fixproto
index eccafcce46c111cead64b476323c57e5d524df10..67241eaead122cfcc26e33ccb3e06650606e8fb1 100755 (executable)
@@ -4,7 +4,7 @@
 #      fixproto TARGET-DIR SOURCE-DIR-ALL SOURCE-DIR-STD
 #
 # COPYRIGHT
-#      Copyright (C) 1993 Free Software Foundation, Inc.
+#      Copyright (C) 1993, 1994 Free Software Foundation, Inc.
 #      This file is part of GNU CC.
 #
 #      GNU CC is free software; you can redistribute it and/or modify
@@ -113,8 +113,9 @@ fi
 required_stdlib_h="abort abs atexit atof atoi atol bsearch calloc exit free getenv labs malloc qsort rand realloc srand strtod strtol strtoul system"
 # "div ldiv", - ignored because these depend on div_t, ldiv_t
 # ignore these: "mblen mbstowcs mbstowc wcstombs wctomb"
+# Left out getgroups, because SunOS4 has incompatible BSD and SVR4 versions.
 # Should perhaps also add NULL
-required_unistd_h="_exit access alarm chdir chown close ctermid cuserid dup dup2 execl execle execlp execv execve execvp fork fpathconf getcwd getegid geteuid getgid getgroups getlogin getpgrp getpid getppid getuid isatty link lseek pathconf pause pipe read rmdir setgid setpgid setsid setuid sleep sysconf tcgetpgrp tcsetpgrp ttyname unlink write"
+required_unistd_h="_exit access alarm chdir chown close ctermid cuserid dup dup2 execl execle execlp execv execve execvp fork fpathconf getcwd getegid geteuid getgid getlogin getpgrp getpid getppid getuid isatty link lseek pathconf pause pipe read rmdir setgid setpgid setsid setuid sleep sysconf tcgetpgrp tcsetpgrp ttyname unlink write"
 
 done_dirs=""
 echo "" >fixproto.list
@@ -135,8 +136,11 @@ for code in ALL STD ; do
        newdirs=
        for d in $dirs ; do
          # Find all directories under $d, relative to $d, excluding $d itself.
+         # Assume directory names ending in CC or containing ++ are
+         # for C++, so skip those.
          subdirs="$subdirs "`cd $rel_source_dir/$d; find . -type d -print | \
-                  sed -e '/^\.$/d' -e "s|^\./|${d}/|" -e 's|^\./||'`
+                  sed -e '/^\.$/d' -e "s|^\./|${d}/|" -e 's|^\./||' \
+                    -e '/CC$/d' -e '/\+\+/d'`
          links=
          links=`cd $rel_source_dir; find $d/. -type l -print | \
                       sed -e "s|$d/./|$d/|" -e 's|^\./||'`
@@ -189,17 +193,32 @@ for code in ALL STD ; do
          do
            new_files_to_check=""
            for file in $files_to_check ; do
+             xxfile=`echo $file | sed -e 's|/\([^/\.][^/\.]*\)/\.\./|/|'`
+             # Create the dir where this file will go when fixed.
+             xxdir=`echo ./$file | sed -e 's|/[^/]*$||'`
+             if [ \! -d $abs_target_subdir/$xxdir ] ; then
+               mkdir $abs_target_subdir/$xxdir
+             fi
+             # Just in case we have edited out a symbolic link
+             if [ -f $src_dir_std/$file -a -f $src_dir_std/$xxfile ] ; then
+               file=$xxfile
+             fi
              case " $rel_source_files " in
                *" ${file} "*)
                  # Already seen $file; nothing to do
                  ;;
                *)
-                 new_files_to_check="$new_files_to_check `sed -n \
+                 if test -f $src_dir_std/$file ; then
+                   rel_dir=`echo $file | sed -n -e 's|^\(.*/\)[^/]*$|\1|p'`
+                   # For #include "foo.h", that might be either "foo.h"
+                   # or "${rel_dir}foo.h (or something bogus).
+                   new_files_to_check="$new_files_to_check "`sed -n \
                        -e 's@  @ @g' \
-                       -e 's@^ *# *include *<\([^>]*\)>.*$@\1@p' \
-                       -e 's@^ *# *include *\"\([^\"]*\)\".*$@\1@p' \
-                       <$src_dir_std/$file`"
-                 rel_source_files="$rel_source_files $file"
+                       -e 's@^ *# *include *<\([^>]*\)>.*$@\1@p' -e \
+                       's@^ *# *include *\"\([^\"]*\)\".*$@\1 '$rel_dir'\1@p'\
+                       <$src_dir_std/$file`
+                   rel_source_files="$rel_source_files $file"
+                 fi
                  ;;
              esac
            done
@@ -259,8 +278,8 @@ for code in ALL STD ; do
              # Most systems that provide them will also declare them.
              required_list="kill raise" ;;
            stdio.h)
-             required_list="clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell fwrite getc getchar gets perror printf putc putchar puts remove rename rewind scanf setbuf setvbuf sprintf sscanf tmpfile tmpnam ungetc vfprintf vprintf vsprintf"
-             if grep _flsbuf <$abs_source_file >/dev/null ; then
+             required_list="clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell fwrite getc getchar gets perror printf putc putchar puts remove rename rewind scanf setbuf setvbuf sprintf sscanf vprintf vsprintf vfprintf tmpfile tmpnam ungetc"
+             if grep '[^_a-zA-Z0-9]_flsbuf' <$abs_source_file >/dev/null; then
                required_list="$required_list _flsbuf _filbuf"
              fi
              # Should perhaps also handle NULL, EOF, ... ?
@@ -271,7 +290,7 @@ for code in ALL STD ; do
              required_list="memchr memcmp memcpy memmove memset strcat strchr strcmp strcoll strcpy strcspn strerror strlen strncat strncmp" ;;
 # Should perhaps also add NULL and size_t
            sys/stat.h)
-             required_list="chmod fstat mkdir mkfifo stat umask"
+             required_list="chmod fstat mkdir mkfifo stat lstat umask"
              extra_check_list="S_ISDIR S_ISBLK S_ISCHR S_ISFIFO S_ISREG S_ISLNK S_IFDIR S_IFBLK S_IFCHR S_IFIFO S_IFREG S_IFLNK" ;;
            sys/times.h)
              required_list="times" ;;
@@ -310,15 +329,27 @@ for code in ALL STD ; do
       rm -f fixtmp.c fixtmp.i
     done
     # check for broken assert.h that needs stdio.h
-    if test -f $abs_source_dir/assert.h -a \! -f $abs_target_dir/assert.h \
-      && grep 'stderr' $abs_source_dir/assert.h >/dev/null
-    then
-      if grep 'include.*stdio.h' $abs_source_dir/assert.h >/dev/null
-      then true
-      else
-       echo 'Fixing broken assert.h (needs stdio.h)'
-       cat $abs_source_dir/assert.h >$abs_target_dir/assert.h
-       echo '#include <stdio.h>' >>$abs_target_dir/assert.h
+    if test -f $abs_source_dir/assert.h -a \! -f $abs_target_dir/assert.h; then
+      if grep 'stderr' $abs_source_dir/assert.h >/dev/null ; then
+       if grep 'include.*stdio.h' $abs_source_dir/assert.h >/dev/null ; then
+         true
+       else
+         echo 'Fixing broken assert.h (needs stdio.h)'
+         cat $abs_source_dir/assert.h >$abs_target_dir/assert.h
+         echo '#include <stdio.h>' >>$abs_target_dir/assert.h
+       fi
+      fi
+      if grep 'exit *(' $abs_source_dir/assert.h >/dev/null || 
+        grep 'abort *(' $abs_source_dir/assert.h >/dev/null ; then
+       if grep 'include.*stdlib.h' $abs_source_dir/assert.h >/dev/null ; then
+         true
+       else
+         echo 'Fixing broken assert.h (needs stdlib.h)'
+         if test ! -f $abs_target_dir/assert.h ; then
+           cat $abs_source_dir/assert.h >$abs_target_dir/assert.h
+         fi
+         echo '#include <stdlib.h>' >>$abs_target_dir/assert.h
+       fi
       fi
     fi
     done_dirs="$done_dir $rel_source_dir"
This page took 0.03601 seconds and 5 git commands to generate.