(input_file_open): Remove call to stat(). Add a check for getc() failing, and
catch the case where the failure is due to an attempt to read a directory.
This commit is contained in:
parent
850742db45
commit
19e7825f04
|
@ -1,3 +1,9 @@
|
||||||
|
2003-12-18 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* input-file.c (input_file_open): Remove call to stat().
|
||||||
|
Add a check for getc() failing, and catch the case where the
|
||||||
|
failure is due to an attempt to read a directory.
|
||||||
|
|
||||||
2003-12-18 Richard Sandiford <rsandifo@redhat.com>
|
2003-12-18 Richard Sandiford <rsandifo@redhat.com>
|
||||||
|
|
||||||
* config/tc-mips.c (mips_need_elf_addend_fixup): Delete.
|
* config/tc-mips.c (mips_need_elf_addend_fixup): Delete.
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <errno.h>
|
||||||
#include "as.h"
|
#include "as.h"
|
||||||
#include "input-file.h"
|
#include "input-file.h"
|
||||||
#include "safe-ctype.h"
|
#include "safe-ctype.h"
|
||||||
|
@ -135,19 +135,6 @@ input_file_open (char *filename, /* "" means use stdin. Must not be 0. */
|
||||||
assert (filename != 0); /* Filename may not be NULL. */
|
assert (filename != 0); /* Filename may not be NULL. */
|
||||||
if (filename[0])
|
if (filename[0])
|
||||||
{
|
{
|
||||||
struct stat statbuf;
|
|
||||||
|
|
||||||
if (stat (filename, &statbuf) < 0)
|
|
||||||
{
|
|
||||||
as_bad (_("%s: No such file"), filename);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (! S_ISREG (statbuf.st_mode))
|
|
||||||
{
|
|
||||||
as_bad (_("'%s' is not an ordinary file"), filename);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
f_in = fopen (filename, FOPEN_RT);
|
f_in = fopen (filename, FOPEN_RT);
|
||||||
file_name = filename;
|
file_name = filename;
|
||||||
}
|
}
|
||||||
|
@ -159,14 +146,32 @@ input_file_open (char *filename, /* "" means use stdin. Must not be 0. */
|
||||||
file_name = _("{standard input}");
|
file_name = _("{standard input}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (f_in == (FILE *) 0)
|
if (f_in)
|
||||||
|
c = getc (f_in);
|
||||||
|
|
||||||
|
if (f_in == NULL || ferror (f_in))
|
||||||
{
|
{
|
||||||
as_bad (_("can't open %s for reading"), file_name);
|
switch (errno)
|
||||||
as_perror ("%s", file_name);
|
{
|
||||||
|
case ENOENT:
|
||||||
|
as_bad (_("%s: no such file"), filename);
|
||||||
|
break;
|
||||||
|
case EISDIR:
|
||||||
|
as_bad (_("%s: is a directory"), filename);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
as_bad (_("can't open %s for reading"), file_name);
|
||||||
|
as_perror ("%s", file_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (f_in)
|
||||||
|
{
|
||||||
|
fclose (f_in);
|
||||||
|
f_in = NULL;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = getc (f_in);
|
|
||||||
if (c == '#')
|
if (c == '#')
|
||||||
{
|
{
|
||||||
/* Begins with comment, may not want to preprocess. */
|
/* Begins with comment, may not want to preprocess. */
|
||||||
|
|
Loading…
Reference in New Issue