* PATCH, COMMIT: Fix handling of empty input files
@ 2010-11-17 11:14 Nick Clifton
2010-11-17 11:17 ` Tristan Gingold
0 siblings, 1 reply; 2+ messages in thread
From: Nick Clifton @ 2010-11-17 11:14 UTC (permalink / raw)
To: binutils
Hi Guys,
I am checking in the patch below to fix a couple of small problems
that gas can encounter when reading from empty input files.
Cheers
Nick
PS. Tristan - would you mind if I applied this patch to the branch ?
gas/ChangeLog
2010-11-17 Nick Clifton <nickc@redhat.com>
* input-file.c (input_file_open): Check for empty input files.
(input_file_get): Check for end of file before reading any more
data.
(input_file_give_next_buffer): Likewise.
Index: input-file.c
===================================================================
RCS file: /cvs/src/src/gas/input-file.c,v
retrieving revision 1.27
diff -u -3 -p -r1.27 input-file.c
--- input-file.c 2 Sep 2009 07:24:19 -0000 1.27
+++ input-file.c 17 Nov 2010 11:09:58 -0000
@@ -157,6 +157,15 @@ input_file_open (char *filename, /* "" m
return;
}
+ /* Check for an empty input file. */
+ if (feof (f_in))
+ {
+ fclose (f_in);
+ f_in = NULL;
+ return;
+ }
+ gas_assert (c != EOF);
+
if (c == '#')
{
/* Begins with comment, may not want to preprocess. */
@@ -209,6 +218,9 @@ input_file_get (char *buf, int buflen)
{
int size;
+ if (feof (f_in))
+ return 0;
+
size = fread (buf, sizeof (char), buflen, f_in);
if (size < 0)
{
@@ -235,7 +247,13 @@ input_file_give_next_buffer (char *where
if (preprocess)
size = do_scrub_chars (input_file_get, where, BUFFER_SIZE);
else
- size = fread (where, sizeof (char), BUFFER_SIZE, f_in);
+ {
+ if (feof (f_in))
+ size = 0;
+ else
+ size = fread (where, sizeof (char), BUFFER_SIZE, f_in);
+ }
+
if (size < 0)
{
as_bad (_("can't read from %s: %s"), file_name, xstrerror (errno));
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: PATCH, COMMIT: Fix handling of empty input files
2010-11-17 11:14 PATCH, COMMIT: Fix handling of empty input files Nick Clifton
@ 2010-11-17 11:17 ` Tristan Gingold
0 siblings, 0 replies; 2+ messages in thread
From: Tristan Gingold @ 2010-11-17 11:17 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils
On Nov 17, 2010, at 12:14 PM, Nick Clifton wrote:
> Hi Guys,
>
> I am checking in the patch below to fix a couple of small problems
> that gas can encounter when reading from empty input files.
>
> Cheers
> Nick
>
> PS. Tristan - would you mind if I applied this patch to the branch ?
It is OK
Tristan.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-17 11:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-17 11:14 PATCH, COMMIT: Fix handling of empty input files Nick Clifton
2010-11-17 11:17 ` Tristan Gingold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).