diff options
author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-23 20:43:54 +0000 |
---|---|---|
committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-10-23 20:43:54 +0000 |
commit | daad4fd542e74d22445a05a5be91761f094d4f27 (patch) | |
tree | 5d5bd3e427e9311346a6f6558c309b3c7348fc9d /libgfortran/io | |
parent | 25b29122d906c4a4c1902a441ac3f2aecff90e5e (diff) | |
download | gcc-daad4fd542e74d22445a05a5be91761f094d4f27.tar.gz |
PR libfortran/23272
* acinclude.m4 (LIBGFOR_CHECK_WORKING_STAT): New check.
* configure.ac: Use LIBGFOR_CHECK_WORKING_STAT.
* Makefile.in: Regenerate.
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* io/unix.c (compare_file_filename): Add fallback case for
systems without working stat.
* io/open.c (already_open): Correct call to
compare_file_filename.
* io/io.h: Correct proto for compare_file_filename.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105824 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/io.h | 2 | ||||
-rw-r--r-- | libgfortran/io/open.c | 2 | ||||
-rw-r--r-- | libgfortran/io/unix.c | 23 |
3 files changed, 21 insertions, 6 deletions
diff --git a/libgfortran/io/io.h b/libgfortran/io/io.h index 3cb98f42ede..5e3adbc42d9 100644 --- a/libgfortran/io/io.h +++ b/libgfortran/io/io.h @@ -450,7 +450,7 @@ internal_proto(output_stream); extern stream *error_stream (void); internal_proto(error_stream); -extern int compare_file_filename (stream *, const char *, int); +extern int compare_file_filename (gfc_unit *, const char *, int); internal_proto(compare_file_filename); extern gfc_unit *find_file (void); diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index e1e42ad9370..203964b5dea 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -415,7 +415,7 @@ already_open (gfc_unit * u, unit_flags * flags) /* If the file is connected to something else, close it and open a new unit. */ - if (!compare_file_filename (u->s, ioparm.file, ioparm.file_len)) + if (!compare_file_filename (u, ioparm.file, ioparm.file_len)) { if (close_unit (u)) { diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c index 91a7a474d07..2026a364927 100644 --- a/libgfortran/io/unix.c +++ b/libgfortran/io/unix.c @@ -1287,10 +1287,13 @@ init_error_stream (void) * filename. */ int -compare_file_filename (stream * s, const char *name, int len) +compare_file_filename (gfc_unit *u, const char *name, int len) { char path[PATH_MAX + 1]; - struct stat st1, st2; + struct stat st1; +#ifdef HAVE_WORKING_STAT + struct stat st2; +#endif if (unpack_filename (path, name, len)) return 0; /* Can't be the same */ @@ -1301,9 +1304,14 @@ compare_file_filename (stream * s, const char *name, int len) if (stat (path, &st1) < 0) return 0; - fstat (((unix_stream *) s)->fd, &st2); - +#ifdef HAVE_WORKING_STAT + fstat (((unix_stream *) (u->s))->fd, &st2); return (st1.st_dev == st2.st_dev) && (st1.st_ino == st2.st_ino); +#else + if (len != u->file_len) + return 0; + return (memcmp(path, u->file, len) == 0); +#endif } @@ -1312,15 +1320,22 @@ compare_file_filename (stream * s, const char *name, int len) static gfc_unit * find_file0 (gfc_unit * u, struct stat *st1) { +#ifdef HAVE_WORKING_STAT struct stat st2; +#endif gfc_unit *v; if (u == NULL) return NULL; +#ifdef HAVE_WORKING_STAT if (fstat (((unix_stream *) u->s)->fd, &st2) >= 0 && st1->st_dev == st2.st_dev && st1->st_ino == st2.st_ino) return u; +#else + if (compare_string(u->file_len, u->file, ioparm.file_len, ioparm.file) == 0) + return u; +#endif v = find_file0 (u->left, st1); if (v != NULL) |