diff options
author | Janne Blomqvist <jb@gcc.gnu.org> | 2015-03-11 23:34:22 +0200 |
---|---|---|
committer | Janne Blomqvist <jb@gcc.gnu.org> | 2015-03-11 23:34:22 +0200 |
commit | 6234b5433f65bf4d1aa1fe2485e7f77f393a860a (patch) | |
tree | 675691d7e2fb5c94061765a40741e081281af137 /libgfortran/io/open.c | |
parent | 707550e43ef8d80a2e2213bc1f4b3af337092d2a (diff) | |
download | gcc-6234b5433f65bf4d1aa1fe2485e7f77f393a860a.zip gcc-6234b5433f65bf4d1aa1fe2485e7f77f393a860a.tar.gz gcc-6234b5433f65bf4d1aa1fe2485e7f77f393a860a.tar.bz2 |
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.
From-SVN: r221361
Diffstat (limited to 'libgfortran/io/open.c')
-rw-r--r-- | libgfortran/io/open.c | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index 0a2fda9..4654de2 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); |