-
/* Install modified versions of certain ANSI-incompatible system header
files which are fixed to work correctly with ANSI C and placed in a
directory that GNU C will search.
#endif
#include <signal.h>
+#if ! defined( SIGCHLD ) && defined( SIGCLD )
+# define SIGCHLD SIGCLD
+#endif
#ifndef SEPARATE_FIX_PROC
#include "server.h"
#endif
te_verbose verbose_level = VERB_PROGRESS;
int have_tty = 0;
-#define VLEVEL(l) (verbose_level >= l)
+#define VLEVEL(l) ((unsigned int) verbose_level >= (unsigned int) l)
#define NOT_SILENT VLEVEL(VERB_FIXES)
pid_t process_chain_head = (pid_t) -1;
# ifdef SEPARATE_FIX_PROC
unlink( pz_temp_file );
# endif
- return EXIT_SUCCESS;
+ exit (EXIT_SUCCESS);
}
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"
-#ifdef __STDC__
"each of these must be defined:\n"
-#define _ENV_(v,m,n,t) "\t" n " - " t "\n"
-ENV_TABLE
-#undef _ENV_
+# define _ENV_(v,m,n,t) "\t" n " - " t "\n"
+ ENV_TABLE
+# undef _ENV_
#endif
;
exit (EXIT_FAILURE);
}
+#ifdef SIGCHLD
+ /* We *MUST* set SIGCHLD to SIG_DFL so that the wait4() call will
+ receive the signal. A different setting is inheritable */
+ 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); \
res = (char*)mmap ((void*)NULL, data_map_size, PROT_READ,
MAP_PRIVATE, data_map_fd, 0);
if (res == (char*)BAD_ADDR)
+#endif
{
+ FILE* fp = fdopen (data_map_fd, "r");
curr_data_mapped = BOOL_FALSE;
- res = load_file_data ( fdopen (data_map_fd, "r"));
+ res = load_file_data (fp);
+ fclose (fp);
}
-#else
- curr_data_mapped = BOOL_FALSE;
- res = load_file_data ( fdopen (data_map_fd, "r"));
-#endif
return res;
}
/*
* Now add the fix number and file names that may be needed
*/
- sprintf (pz_scan, "%ld %s %s %s", p_fixd - fixDescList,
+ sprintf (pz_scan, "%ld \'%s\' \'%s\' \'%s\'", p_fixd - fixDescList,
pz_fix_file, pz_file_source, pz_temp_file);
}
else /* NOT an "internal" fix: */
the following bizarre use of 'cat' only works on DOS boxes.
It causes the file to be dropped into a temporary file for
'cat' to read (pipes do not work on DOS). */
- tSCC z_cmd_fmt[] = " %s | cat > %s";
+ tSCC z_cmd_fmt[] = " \'%s\' | cat > \'%s\'";
#else
/* Don't use positional formatting arguments because some lame-o
implementations cannot cope :-(. */
int fd;
fd = chain_open (read_fd,
- (t_pchar *) p_fixd->patch_args,
+ (tCC **) p_fixd->patch_args,
(process_chain_head == -1)
? &process_chain_head : (pid_t *) NULL);
{
FILE *in_fp = fdopen (read_fd, "r");
FILE *out_fp = (FILE *) NULL;
- char *pz_cmp = pz_curr_data;
+ unsigned char *pz_cmp = (unsigned char*)pz_curr_data;
#ifdef DO_STATS
fixed_ct++;
ch = getc (in_fp);
if (ch == EOF)
break;
+ ch &= 0xFF; /* all bytes are 8 bits */
/* IF we are emitting the output
THEN emit this character, too.
altered_ct++;
#endif
/* IF there are matched data, write the matched part now. */
- if (pz_cmp != pz_curr_data)
- fwrite (pz_curr_data, (size_t)(pz_cmp - pz_curr_data), 1, out_fp);
+ if ((char*)pz_cmp != pz_curr_data)
+ fwrite (pz_curr_data, (size_t)((char*)pz_cmp - pz_curr_data),
+ 1, out_fp);
/* Emit the current unmatching character */
putc (ch, out_fp);
read_fd = open (pz_temp_file, O_RDONLY);
if (read_fd < 0)
{
- fprintf (stderr, "error %d (%s) opening output (%s) for read\n",
- errno, xstrerror (errno), pz_temp_file);
+ if (errno != ENOENT)
+ fprintf (stderr, "error %d (%s) opening output (%s) for read\n",
+ errno, xstrerror (errno), pz_temp_file);
}
else
{