aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-11 21:34:22 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2015-03-11 21:34:22 +0000
commit771e2b1c3ccaa6fd2cc05a07a47eafa252f7286a (patch)
tree675691d7e2fb5c94061765a40741e081281af137 /libgfortran
parentfd2e7f43dbcd5f3d5e885a72fe70955166498d8a (diff)
PR 65200 Handle EPERM in addition to EACCES.
gcc/fortran ChangeLog: 2015-03-11 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/65200 * gfortran.texi: Document behavior when opening files without explicit ACTION= specifier. libgfortran ChangeLog: 2015-03-11 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/65200 * io/open.c (new_unit): Use gf_strerror rather than hardcoding error messages for different errno values. * io/unix.c (regular_file2): Handle EPERM in addition to EACCES. gcc/testsuite ChangeLog: 2015-03-11 Janne Blomqvist <jb@gcc.gnu.org> PR libfortran/65200 * gfortran.dg/open_errors.f90: Update checks for iomsg string. * gfortran.dg/open_new_segv.f90: Fix error message pattern. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221361 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/open.c30
-rw-r--r--libgfortran/io/unix.c4
3 files changed, 13 insertions, 28 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 184338aaede..97ee01b59fc 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2015-03-11 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/65200
+ * io/open.c (new_unit): Use gf_strerror rather than hardcoding
+ error messages for different errno values.
+ * io/unix.c (regular_file2): Handle EPERM in addition to EACCES.
+
2015-03-10 Alessandro Fanfarillo <fanfarillo.gcc@gmail.com>
Tobias Burnus <burnus@net-b.de>
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index 0a2fda9d476..4654de27bd1 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -502,34 +502,12 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags)
s = open_external (opp, flags);
if (s == NULL)
{
+ char errbuf[256];
char *path = fc_strdup (opp->file, opp->file_len);
- size_t msglen = opp->file_len + 51;
+ size_t msglen = opp->file_len + 22 + sizeof (errbuf);
char *msg = xmalloc (msglen);
-
- switch (errno)
- {
- case ENOENT:
- snprintf (msg, msglen, "File '%s' does not exist", path);
- break;
-
- case EEXIST:
- snprintf (msg, msglen, "File '%s' already exists", path);
- break;
-
- case EACCES:
- snprintf (msg, msglen,
- "Permission denied trying to open file '%s'", path);
- break;
-
- case EISDIR:
- snprintf (msg, msglen, "'%s' is a directory", path);
- break;
-
- default:
- free (msg);
- msg = NULL;
- }
-
+ snprintf (msg, msglen, "Cannot open file '%s': %s", path,
+ gf_strerror (errno, errbuf, sizeof (errbuf)));
generate_error (&opp->common, LIBERROR_OS, msg);
free (msg);
free (path);
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 912364b56db..e5fc6e19818 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1353,7 +1353,7 @@ regular_file2 (const char *path, st_parameter_open *opp, unit_flags *flags)
flags->action = ACTION_READWRITE;
return fd;
}
- if (errno != EACCES && errno != EROFS)
+ if (errno != EACCES && errno != EPERM && errno != EROFS)
return fd;
/* retry for read-only access */
@@ -1369,7 +1369,7 @@ regular_file2 (const char *path, st_parameter_open *opp, unit_flags *flags)
return fd; /* success */
}
- if (errno != EACCES && errno != ENOENT)
+ if (errno != EACCES && errno != EPERM && errno != ENOENT)
return fd; /* failure */
/* retry for write-only access */