From 48ac9ce28c62ff92048a97fd02af394668f027eb Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Thu, 20 May 1999 07:10:41 +0000 Subject: [PATCH] static initialization removal & K&R-ification From-SVN: r27052 --- gcc/ChangeLog | 10 ++++++++++ gcc/fixinc/Makefile.in | 4 ++-- gcc/fixinc/fixincl.c | 37 ++++++++++++++++++++++++------------- gcc/fixinc/gnu-regex.c | 10 ++++++++++ gcc/fixinc/procopen.c | 4 +++- gcc/fixinc/server.c | 4 ++++ 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5a20e941705..e01e1489f76 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +Thu May 20 07:06:39 1999 Alexandre Oliva + + * fixinc/Makefile.in(gnu-regex.o): add $(INCLUDES) to compile options + * fixinc/fixincl.c(wait_for_pid): K&R-ify arguments + (several places): omit static initialization + (process): use single fd, since only the read fd is used + * fixinc/gnu-regex.c: define 'const' away, if not supported + * fixinc/procopen.c(several places): omit static initialization + * fixinc/server.c: define 'volitile' away, if not supported + 1999-05-20 Andreas Schwab * config/dbxcoff.h (DBX_OUTPUT_MAIN_SOURCE_FILE_END): Use diff --git a/gcc/fixinc/Makefile.in b/gcc/fixinc/Makefile.in index 2ba932f8c6f..8976c783e72 100644 --- a/gcc/fixinc/Makefile.in +++ b/gcc/fixinc/Makefile.in @@ -81,8 +81,8 @@ fixincl: $(OBJ) chmod 777 $@ ; fi gnu-regex.o: gnu-regex.c - -$(CC) $(CFLAGS) $(FIXINC_DEFS) -DREGEX_MALLOC -DSTDC_HEADERS=1 \ - -c $(srcdir)/gnu-regex.c + -$(CC) $(CFLAGS) $(FIXINC_DEFS) $(INCLUDES) -DREGEX_MALLOC \ + -DSTDC_HEADERS=1 -c $(srcdir)/gnu-regex.c fixincl.o : fixincl.x fixincl.c server.o : server.c server.h diff --git a/gcc/fixinc/fixincl.c b/gcc/fixinc/fixincl.c index c3da20f591c..f4cd5ec1cee 100644 --- a/gcc/fixinc/fixincl.c +++ b/gcc/fixinc/fixincl.c @@ -58,6 +58,13 @@ static const char program_id[] = "fixincl version 1.0"; #endif #define NAME_TABLE_SIZE (MINIMUM_MAXIMUM_LINES * MAXPATHLEN) +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif + char *file_name_buf; #define tSCC static const char @@ -382,7 +389,9 @@ initialize() `waitpid(2)'. We also ensure that the children exit with success. */ void -wait_for_pid( pid_t child, int file_name_ct ) +wait_for_pid(child, file_name_ct) + pid_t child; + int file_name_ct; { for (;;) { int status; @@ -934,18 +943,20 @@ process (pz_data, pz_file_name) char *pz_data; const char *pz_file_name; { - static char env_current_file[1024] = { "file=" }; + static char env_current_file[1024]; tFixDesc *p_fixd = fixDescList; int todo_ct = FIX_COUNT; - t_fd_pair fdp = { -1, -1 }; + int read_fd = -1; int num_children = 0; /* IF this is the first time through, THEN put the 'file' environment variable into the environment. This is used by some of the subject shell scripts and tests. */ - if (env_current_file[5] == NUL) + if (env_current_file[0] == NUL) { + strcpy (env_current_file, "file="); putenv (env_current_file); + } /* Ghastly as it is, this actually updates the value of the variable: @@ -1059,10 +1070,10 @@ process (pz_data, pz_file_name) the first fix. Any subsequent fixes will use the stdout descriptor of the previous fix as its stdin. */ - if (fdp.read_fd == -1) + if (read_fd == -1) { - fdp.read_fd = open (pz_file_name, O_RDONLY); - if (fdp.read_fd < 0) + read_fd = open (pz_file_name, O_RDONLY); + if (read_fd < 0) { fprintf (stderr, "Error %d (%s) opening %s\n", errno, strerror (errno), pz_file_name); @@ -1071,7 +1082,7 @@ process (pz_data, pz_file_name) } /* This loop should only cycle for 1/2 of one loop. - "chain_open" starts a process that uses "fdp.read_fd" as + "chain_open" starts a process that uses "read_fd" as its stdin and returns the new fd this process will use for stdout. */ @@ -1079,14 +1090,14 @@ process (pz_data, pz_file_name) { tSCC z_err[] = "Error %d (%s) starting filter process for %s\n"; static int failCt = 0; - int fd = chain_open (fdp.read_fd, + int fd = chain_open (read_fd, (t_pchar *) p_fixd->patch_args, (process_chain_head == -1) ? &process_chain_head : (pid_t *) NULL); if (fd != -1) { - fdp.read_fd = fd; + read_fd = fd; num_children++; break; } @@ -1106,7 +1117,7 @@ process (pz_data, pz_file_name) /* IF after all the tests we did not start any patch programs, THEN quit now. */ - if (fdp.read_fd < 0) + if (read_fd < 0) return; /* OK. We have work to do. Read back in the output @@ -1117,7 +1128,7 @@ process (pz_data, pz_file_name) output of the filter chain. */ { - FILE *in_fp = fdopen (fdp.read_fd, "r"); + FILE *in_fp = fdopen (read_fd, "r"); FILE *out_fp = (FILE *) NULL; char *pz_cmp = pz_data; @@ -1173,7 +1184,7 @@ process (pz_data, pz_file_name) } fclose (in_fp); } - close (fdp.read_fd); /* probably redundant, but I'm paranoid */ + close (read_fd); /* probably redundant, but I'm paranoid */ /* Wait for child processes created by chain_open() to avoid creating zombies. */ diff --git a/gcc/fixinc/gnu-regex.c b/gcc/fixinc/gnu-regex.c index 84db70f7952..b24845ba431 100644 --- a/gcc/fixinc/gnu-regex.c +++ b/gcc/fixinc/gnu-regex.c @@ -80,6 +80,16 @@ #else /* not emacs */ +# include "auto-host.h" + +# if !defined(const) && !defined(HAVE_CONST) +# define const +# endif + +# if !defined(volatile) && !defined(HAVE_VOLATILE) +# define volatile +# endif + /* If we are not linking with Emacs proper, we can't use the relocating allocator even if config.h says that we can. */ diff --git a/gcc/fixinc/procopen.c b/gcc/fixinc/procopen.c index 28004eed8a7..00f13b7ae97 100644 --- a/gcc/fixinc/procopen.c +++ b/gcc/fixinc/procopen.c @@ -104,10 +104,12 @@ chain_open (stdin_fd, pp_args, p_child) t_pchar *pp_args; pid_t *p_child; { - t_fd_pair stdout_pair = {-1, -1}; + t_fd_pair stdout_pair; pid_t ch_id; char *pz_cmd; + stdout_pair.read_fd = stdout_pair.write_fd = -1; + /* * Create a pipe it will be the child process' stdout, * and the parent will read from it. diff --git a/gcc/fixinc/server.c b/gcc/fixinc/server.c index e803e0a29ce..4af40e5eb96 100644 --- a/gcc/fixinc/server.c +++ b/gcc/fixinc/server.c @@ -86,6 +86,10 @@ #define NUL '\0' #endif +#if !defined(volatile) && !defined(HAVE_VOLATILE) +# define volatile +#endif + STATIC volatile bool read_pipe_timeout; static t_pchar def_args[] = -- 2.30.2