do not rely on load_file_data() to close file pointer

From-SVN: r39501
This commit is contained in:
Bruce Korb 2001-02-06 22:19:50 +00:00 committed by Bruce Korb
parent 3c8465d077
commit ca21b4a51c
4 changed files with 20 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2001-01-30 Bruce Korb <bkorb@gnu.org>
fixinc/fixincl.c(process): Emit error message only if appropriate :)
(load_file): do not rely on load_file_data() to close file pointer
fixinc/fixlib.c(load_file_data): do not close passed in file pointer
fixinc/inclhack.def(irix_limits_const): add test_text
2001-02-06 Neil Booth <neil@daikokuya.demon.co.uk>
* cppexp.c (parse_defined): Improve diagnostics for invalid

View File

@ -364,14 +364,13 @@ load_file ( fname )
res = (char*)mmap ((void*)NULL, data_map_size, PROT_READ,
MAP_PRIVATE, data_map_fd, 0);
if (res == (char*)BAD_ADDR)
{
curr_data_mapped = BOOL_FALSE;
res = load_file_data ( fdopen (data_map_fd, "r"));
}
#else
curr_data_mapped = BOOL_FALSE;
res = load_file_data ( fdopen (data_map_fd, "r"));
#endif
{
FILE* fp = fdopen (data_map_fd, "r");
curr_data_mapped = BOOL_FALSE;
res = load_file_data (fp);
fclose (fp);
}
return res;
}
@ -1431,8 +1430,9 @@ process ()
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
{

View File

@ -39,6 +39,9 @@ load_file_data (fp)
int space_left = -1; /* allow for terminating NUL */
size_t space_used = 0;
if (fp == (FILE*)NULL)
return pz_data;
do
{
size_t size_read;
@ -62,7 +65,6 @@ load_file_data (fp)
fprintf (stderr, "error %d (%s) reading input\n", err,
xstrerror (err));
free ((void *) pz_data);
fclose (fp);
return (char *) NULL;
}
}
@ -73,7 +75,6 @@ load_file_data (fp)
pz_data = xrealloc ((void*)pz_data, space_used+1 );
pz_data[ space_used ] = NUL;
fclose (fp);
return pz_data;
}

View File

@ -1292,6 +1292,7 @@ fix = {
select = "^extern const ";
c_fix = format;
c_fix_arg = "extern __const ";
test_text = "extern const char limit; /* test\n\tlimits */";
};