diff options
author | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-15 07:58:38 +0000 |
---|---|---|
committer | bonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-10-15 07:58:38 +0000 |
commit | 4f80d25b87fcbbec22e05d3894d0e6e47b2f1163 (patch) | |
tree | 0988a96569fcf89616a90abf081927a8c8328cf8 /fixincludes/fixincl.c | |
parent | 38ddce4759617c496335aab7ee3a0fe17adbe569 (diff) | |
download | gcc-4f80d25b87fcbbec22e05d3894d0e6e47b2f1163.tar.gz |
2004-08-14 Paolo Bonzini <bonzini@gnu.org>
PR other/17991
* Makefile.in (ALLOBJ, TESTOBJ, FIXOBJ): Add fixopts.o.
Update copyright year.
* fixfixes.c (main): Call initialize_opts from fixopts.c.
* fixincl.c (initialize): Call initialize_opts from fixopts.c,
do not include code for parsing options (environment vars).
(fix_with_system): Use a search path for applyfix, so that you
can run the test suite with two-process fixincludes.
* fixopts.c: New file.
* configure.ac: Add --enable-twoprocess. Export ac_exeext
to config.h. Default to --enable-twoprocess for MinGW32.
* config.h.in: Regenerate.
* configure: Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@89087 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'fixincludes/fixincl.c')
-rw-r--r-- | fixincludes/fixincl.c | 88 |
1 files changed, 37 insertions, 51 deletions
diff --git a/fixincludes/fixincl.c b/fixincludes/fixincl.c index 690184b8ad7..a153a777a54 100644 --- a/fixincludes/fixincl.c +++ b/fixincludes/fixincl.c @@ -2,7 +2,7 @@ files which are fixed to work correctly with ANSI C and placed in a directory that GCC will search. - Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1997, 1998, 1999, 2000, 2004 Free Software Foundation, Inc. This file is part of GCC. @@ -23,6 +23,8 @@ Boston, MA 02111-1307, USA. */ #include "fixlib.h" +#include <sys/stat.h> + #if defined( HAVE_MMAP_FILE ) #include <sys/mman.h> #define BAD_ADDR ((void*)-1) @@ -49,12 +51,6 @@ static const char z_std_preamble[] = This had to be done to correct non-standard usages in the\n\ original, manufacturer supplied header file. */\n\n"; -/* Working environment strings. Essentially, invocation 'options'. */ - -#define _ENV_(v,m,n,t) tCC* v = NULL; -ENV_TABLE -#undef _ENV_ - int find_base_len = 0; typedef enum { @@ -214,18 +210,6 @@ do_version (void) void initialize ( int argc, char** argv ) { - static const char var_not_found[] = -#ifndef __STDC__ - "fixincl ERROR: %s environment variable not defined\n" -#else - "fixincl ERROR: %s environment variable not defined\n" - "each of these must be defined:\n" -# define _ENV_(vv,mm,nn,tt) "\t" nn " - " tt "\n" - ENV_TABLE -# undef _ENV_ -#endif - ; - xmalloc_set_program_name (argv[0]); switch (argc) @@ -255,14 +239,7 @@ initialize ( int argc, char** argv ) signal (SIGCHLD, SIG_DFL); #endif -#define _ENV_(v,m,n,t) { tSCC var[] = n; \ - v = getenv (var); if (m && (v == NULL)) { \ - fprintf (stderr, var_not_found, var); \ - exit (EXIT_FAILURE); } } - -ENV_TABLE - -#undef _ENV_ + initialize_opts (); if (ISDIGIT ( *pz_verbose )) verbose_level = (te_verbose)atoi( pz_verbose ); @@ -877,32 +854,41 @@ fix_with_system (tFixDesc* p_fixd, char* pz_cmd; char* pz_scan; size_t argsize; + int i; + tSCC z_applyfix_prog[2] = { + "/../fixincludes/applyfix" EXE_EXT, + "/../../fixincludes/applyfix" EXE_EXT }; if (p_fixd->fd_flags & FD_SUBROUTINE) - { - tSCC z_applyfix_prog[] = "/fixinc/applyfix"; - - argsize = 32 - + strlen( pz_orig_dir ) - + sizeof( z_applyfix_prog ) - + strlen( pz_fix_file ) - + strlen( pz_file_source ) - + strlen( pz_temp_file ); - - pz_cmd = xmalloc (argsize); - - strcpy( pz_cmd, pz_orig_dir ); - pz_scan = pz_cmd + strlen( pz_orig_dir ); - strcpy( pz_scan, z_applyfix_prog ); - pz_scan += sizeof( z_applyfix_prog ) - 1; - *(pz_scan++) = ' '; - - /* - * Now add the fix number and file names that may be needed - */ - sprintf (pz_scan, "%ld \'%s\' \'%s\' \'%s\'", p_fixd - fixDescList, - pz_fix_file, pz_file_source, pz_temp_file); - } + for (i = 0; i < 2; i++) + { + struct stat buf; + + argsize = 32 + + strlen( pz_orig_dir ) + + sizeof( z_applyfix_prog ) + + strlen( pz_fix_file ) + + strlen( pz_file_source ) + + strlen( pz_temp_file ); + + pz_cmd = xmalloc (argsize); + + strcpy( pz_cmd, pz_orig_dir ); + pz_scan = pz_cmd + strlen( pz_orig_dir ); + strcpy( pz_scan, z_applyfix_prog ); + pz_scan += sizeof( z_applyfix_prog ) - 1; + + if (stat (pz_scan, &buf) != -1) + { + *(pz_scan++) = ' '; + /* + * Now add the fix number and file names that may be needed + */ + sprintf (pz_scan, "%ld \'%s\' \'%s\' \'%s\'", p_fixd - fixDescList, + pz_fix_file, pz_file_source, pz_temp_file); + break; + } + } else /* NOT an "internal" fix: */ { size_t parg_size; |