aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-11-07 12:19:34 +0000
committerNick Clifton <nickc@redhat.com>2003-11-07 12:19:34 +0000
commitf24ddbddc5177a930b867626b12d2bb8b3757223 (patch)
treefe1b8c0703b20b4e188b7c432488a7e2f8874ab1 /gas
parent65ed7f0a337f0c802f4a7c096c833f20c99dfb3e (diff)
downloadbinutils-f24ddbddc5177a930b867626b12d2bb8b3757223.zip
binutils-f24ddbddc5177a930b867626b12d2bb8b3757223.tar.gz
binutils-f24ddbddc5177a930b867626b12d2bb8b3757223.tar.bz2
Use consistent error messages for missing files.
Detect directories where an ordinary file is expected.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog5
-rw-r--r--gas/input-file.c25
2 files changed, 26 insertions, 4 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 57cf9ff..fadb9c3 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2003-11-07 Jonathan R. Grant <jg-binutils@jguk.org>
+
+ * input-file.c (input_file_open): Use "No such file" error
+ message.
+
2003-11-06 Pete Gonzalez <pgonzalez@bluel.com>
* config/tc-arm.texi (struct reg_entry): Add new field 'builtin'.
diff --git a/gas/input-file.c b/gas/input-file.c
index b6c91ed..8e73615 100644
--- a/gas/input-file.c
+++ b/gas/input-file.c
@@ -1,5 +1,5 @@
/* input_file.c - Deal with Input Files -
- Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001
+ Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1999, 2000, 2001, 2003
Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -26,6 +26,7 @@
#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
#include "as.h"
#include "input-file.h"
#include "safe-ctype.h"
@@ -135,15 +136,31 @@ input_file_open (filename, pre)
assert (filename != 0); /* Filename may not be NULL. */
if (filename[0])
- { /* We have a file name. Suck it and see. */
+ {
+ 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);
file_name = filename;
}
else
- { /* use stdin for the input file. */
+ {
+ /* Use stdin for the input file. */
f_in = stdin;
- file_name = _("{standard input}"); /* For error messages. */
+ /* For error messages. */
+ file_name = _("{standard input}");
}
+
if (f_in == (FILE *) 0)
{
as_bad (_("can't open %s for reading"), file_name);