summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-05 00:51:26 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2006-12-05 00:51:26 +0000
commit659469f5896d10141c2ab949447fd8cd92bfb0b1 (patch)
tree183a941f2c393552c39658128aff3a7f90722949
parentdcead90ecd299239015124a21bff7243a03fe9d3 (diff)
downloadppe42-gcc-659469f5896d10141c2ab949447fd8cd92bfb0b1.tar.gz
ppe42-gcc-659469f5896d10141c2ab949447fd8cd92bfb0b1.zip
2006-12-04 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/30005 * io/open.c: Add errno.h include. (new_unit): Add new error messages with file name for file open. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119530 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/io/open.c30
2 files changed, 35 insertions, 1 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index ca823924d0b..8844e9ad336 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-04 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/30005
+ * io/open.c: Add errno.h include.
+ (new_unit): Add new error messages with file name for file open.
+
2006-12-01 Thomas Koenig <Thomas.Koenig@online.de>
PR libfortran/29568
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index 06fba75e1df..ef1ce1e0228 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -32,6 +32,7 @@ Boston, MA 02110-1301, USA. */
#include <unistd.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include "libgfortran.h"
#include "io.h"
@@ -374,7 +375,34 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags)
s = open_external (opp, flags);
if (s == NULL)
{
- generate_error (&opp->common, ERROR_OS, NULL);
+ char *path, *msg;
+ path = (char *) gfc_alloca (opp->file_len + 1);
+ msg = (char *) gfc_alloca (opp->file_len + 51);
+ unpack_filename (path, opp->file, opp->file_len);
+
+ switch (errno)
+ {
+ case ENOENT:
+ st_sprintf (msg, "File '%s' does not exist", path);
+ break;
+
+ case EEXIST:
+ st_sprintf (msg, "File '%s' already exists", path);
+ break;
+
+ case EACCES:
+ st_sprintf (msg, "Permission denied trying to open file '%s'", path);
+ break;
+
+ case EISDIR:
+ st_sprintf (msg, "'%s' is a directory", path);
+ break;
+
+ default:
+ msg = NULL;
+ }
+
+ generate_error (&opp->common, ERROR_OS, msg);
goto cleanup;
}
OpenPOWER on IntegriCloud