static initialization removal & K&R-ification

From-SVN: r27053
This commit is contained in:
Alexandre Oliva 1999-05-20 07:15:14 +00:00 committed by Bruce Korb
parent df118d7bcc
commit df89c5dd10
6 changed files with 53 additions and 16 deletions

View File

@ -1,3 +1,13 @@
Thu May 20 07:06:39 1999 Alexandre Oliva <aoliva@acm.org>
* 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 <schwab@issan.cs.uni-dortmund.de> 1999-05-20 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
* config/dbxcoff.h (DBX_OUTPUT_MAIN_SOURCE_FILE_END): Use * config/dbxcoff.h (DBX_OUTPUT_MAIN_SOURCE_FILE_END): Use

View File

@ -81,8 +81,8 @@ fixincl: $(OBJ)
chmod 777 $@ ; fi chmod 777 $@ ; fi
gnu-regex.o: gnu-regex.c gnu-regex.o: gnu-regex.c
-$(CC) $(CFLAGS) $(FIXINC_DEFS) -DREGEX_MALLOC -DSTDC_HEADERS=1 \ -$(CC) $(CFLAGS) $(FIXINC_DEFS) $(INCLUDES) -DREGEX_MALLOC \
-c $(srcdir)/gnu-regex.c -DSTDC_HEADERS=1 -c $(srcdir)/gnu-regex.c
fixincl.o : fixincl.x fixincl.c fixincl.o : fixincl.x fixincl.c
server.o : server.c server.h server.o : server.c server.h

View File

@ -58,6 +58,13 @@ static const char program_id[] = "fixincl version 1.0";
#endif #endif
#define NAME_TABLE_SIZE (MINIMUM_MAXIMUM_LINES * MAXPATHLEN) #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; char *file_name_buf;
#define tSCC static const char #define tSCC static const char
@ -382,7 +389,9 @@ initialize()
`waitpid(2)'. We also ensure that the children exit with success. */ `waitpid(2)'. We also ensure that the children exit with success. */
void 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 (;;) { for (;;) {
int status; int status;
@ -934,18 +943,20 @@ process (pz_data, pz_file_name)
char *pz_data; char *pz_data;
const char *pz_file_name; const char *pz_file_name;
{ {
static char env_current_file[1024] = { "file=" }; static char env_current_file[1024];
tFixDesc *p_fixd = fixDescList; tFixDesc *p_fixd = fixDescList;
int todo_ct = FIX_COUNT; int todo_ct = FIX_COUNT;
t_fd_pair fdp = { -1, -1 }; int read_fd = -1;
int num_children = 0; int num_children = 0;
/* IF this is the first time through, /* IF this is the first time through,
THEN put the 'file' environment variable into the environment. THEN put the 'file' environment variable into the environment.
This is used by some of the subject shell scripts and tests. */ 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); putenv (env_current_file);
}
/* /*
Ghastly as it is, this actually updates the value of the variable: 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 the first fix. Any subsequent fixes will use the
stdout descriptor of the previous fix as its stdin. */ 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); read_fd = open (pz_file_name, O_RDONLY);
if (fdp.read_fd < 0) if (read_fd < 0)
{ {
fprintf (stderr, "Error %d (%s) opening %s\n", errno, fprintf (stderr, "Error %d (%s) opening %s\n", errno,
strerror (errno), pz_file_name); 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. /* 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 its stdin and returns the new fd this process will use
for stdout. */ for stdout. */
@ -1079,14 +1090,14 @@ process (pz_data, pz_file_name)
{ {
tSCC z_err[] = "Error %d (%s) starting filter process for %s\n"; tSCC z_err[] = "Error %d (%s) starting filter process for %s\n";
static int failCt = 0; static int failCt = 0;
int fd = chain_open (fdp.read_fd, int fd = chain_open (read_fd,
(t_pchar *) p_fixd->patch_args, (t_pchar *) p_fixd->patch_args,
(process_chain_head == -1) (process_chain_head == -1)
? &process_chain_head : (pid_t *) NULL); ? &process_chain_head : (pid_t *) NULL);
if (fd != -1) if (fd != -1)
{ {
fdp.read_fd = fd; read_fd = fd;
num_children++; num_children++;
break; break;
} }
@ -1106,7 +1117,7 @@ process (pz_data, pz_file_name)
/* IF after all the tests we did not start any patch programs, /* IF after all the tests we did not start any patch programs,
THEN quit now. */ THEN quit now. */
if (fdp.read_fd < 0) if (read_fd < 0)
return; return;
/* OK. We have work to do. Read back in the output /* 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. 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; FILE *out_fp = (FILE *) NULL;
char *pz_cmp = pz_data; char *pz_cmp = pz_data;
@ -1173,7 +1184,7 @@ process (pz_data, pz_file_name)
} }
fclose (in_fp); 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() /* Wait for child processes created by chain_open()
to avoid creating zombies. */ to avoid creating zombies. */

View File

@ -80,6 +80,16 @@
#else /* not emacs */ #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, /* If we are not linking with Emacs proper,
we can't use the relocating allocator we can't use the relocating allocator
even if config.h says that we can. */ even if config.h says that we can. */

View File

@ -104,10 +104,12 @@ chain_open (stdin_fd, pp_args, p_child)
t_pchar *pp_args; t_pchar *pp_args;
pid_t *p_child; pid_t *p_child;
{ {
t_fd_pair stdout_pair = {-1, -1}; t_fd_pair stdout_pair;
pid_t ch_id; pid_t ch_id;
char *pz_cmd; char *pz_cmd;
stdout_pair.read_fd = stdout_pair.write_fd = -1;
/* /*
* Create a pipe it will be the child process' stdout, * Create a pipe it will be the child process' stdout,
* and the parent will read from it. * and the parent will read from it.

View File

@ -86,6 +86,10 @@
#define NUL '\0' #define NUL '\0'
#endif #endif
#if !defined(volatile) && !defined(HAVE_VOLATILE)
# define volatile
#endif
STATIC volatile bool read_pipe_timeout; STATIC volatile bool read_pipe_timeout;
static t_pchar def_args[] = static t_pchar def_args[] =