--- gcc/fixproto 2018/04/24 18:12:09 1.1 +++ gcc/fixproto 2018/04/24 18:18:58 1.1.1.2 @@ -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 @@ -57,6 +57,8 @@ progname=$0 progname=`basename $progname` original_dir=`pwd` CPP=${CPP-./cpp} +FIX_HEADER=${FIX_HEADER-$original_dir/fix-header} +DEFINES="-D__STDC__=0 -D__cplusplus ${FIXPROTO_DEFINES}" if [ `echo $1 | wc -w` = 0 ] ; then echo $progname\: usage\: $progname target-dir \[ source-dir \.\.\. \] @@ -110,11 +112,12 @@ if [ `echo $* | wc -w` != 0 ] ; then done 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" +required_stdlib_h="abort abs atexit atof atoi atol bsearch calloc exit free getenv labs malloc putenv 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 getopt 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 @@ -277,7 +280,7 @@ 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 vprintf vsprintf vfprintf tmpfile tmpnam ungetc" + required_list="clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell fwrite getc getchar gets pclose perror popen 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 @@ -286,10 +289,10 @@ for code in ALL STD ; do stdlib.h) required_list="$required_stdlib_h" ;; string.h) - required_list="memchr memcmp memcpy memmove memset strcat strchr strcmp strcoll strcpy strcspn strerror strlen strncat strncmp" ;; + required_list="memchr memcmp memcpy memmove memset strcat strchr strcmp strcoll strcpy strcspn strerror strlen strncat strncmp strncpy strpbrk strrchr strspn strstr strtok strxfrm" ;; # 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" ;; @@ -316,9 +319,9 @@ for code in ALL STD ; do echo "__DEFINED_MACRO_${macro};" >>fixtmp.c echo "#endif" >>fixtmp.c done - if ${CPP} -D__STDC__ -D__cplusplus -D_POSIX_SOURCE $include_path fixtmp.c >fixtmp.i 2>/dev/null + if ${CPP} ${DEFINES} $include_path fixtmp.c >fixtmp.i 2>/dev/null then - $original_dir/fix-header $rel_source_file $abs_source_file $abs_target_file "$required_list" /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 ' >>$abs_target_dir/assert.h - fi - fi done_dirs="$done_dir $rel_source_dir" done @@ -357,7 +348,7 @@ do #define ${rel_source_ident} #endif EOF - $original_dir/fix-header $rel_source_file tmp.h $abs_target_dir/$rel_source_file "$required_list"