summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2010-03-20 14:39:00 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2010-03-20 14:39:00 +0000
commitf4e9c6767d0ea69e572b5046f87d0aacef588f84 (patch)
tree1f0dd89e327efd48666fe5142e7c12087383968d
parent0895c53c41cfab6c1522b9b02ad9edb35b6724f2 (diff)
downloadgcc-f4e9c6767d0ea69e572b5046f87d0aacef588f84.tar.gz
2010-03-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/43409 * ioparm.def: Change inquire size variable to type pointer to GFC_IO_INT type. 2010-03-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/43409 * io/unix.h: Add prototype for new function to return file size. * io/unix.c (file_size): New function. * io/inquire.c (inquire_via_unit): Use new function. (inquire_via_filename): Use new function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157593 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog6
-rw-r--r--gcc/fortran/ioparm.def2
-rw-r--r--libgfortran/ChangeLog10
-rw-r--r--libgfortran/io/inquire.c11
-rw-r--r--libgfortran/io/unix.c16
-rw-r--r--libgfortran/io/unix.h3
6 files changed, 46 insertions, 2 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index dc155fa1574..d8a2d3ee790 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,9 @@
+2010-03-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR fortran/43409
+ * ioparm.def: Change inquire size variable to type pointer to
+ GFC_IO_INT type.
+
2010-03-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/43039
diff --git a/gcc/fortran/ioparm.def b/gcc/fortran/ioparm.def
index 7de7a5101dc..ba1ba232b44 100644
--- a/gcc/fortran/ioparm.def
+++ b/gcc/fortran/ioparm.def
@@ -85,7 +85,7 @@ IOPARM (inquire, encoding, 1 << 2, char1)
IOPARM (inquire, round, 1 << 3, char2)
IOPARM (inquire, sign, 1 << 4, char1)
IOPARM (inquire, pending, 1 << 5, pint4)
-IOPARM (inquire, size, 1 << 6, pint4)
+IOPARM (inquire, size, 1 << 6, pintio)
IOPARM (inquire, id, 1 << 7, pint4)
IOPARM (wait, common, 0, common)
IOPARM (wait, id, 1 << 7, pint4)
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 6f2198b48ad..7a80556532c 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,7 +1,15 @@
+2010-03-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR fortran/43409
+ * io/unix.h: Add prototype for new function to return file size.
+ * io/unix.c (file_size): New function.
+ * io/inquire.c (inquire_via_unit): Use new function.
+ (inquire_via_filename): Use new function.
+
2010-03-17 Jerry DeLisle <jvdelisle@gcc.gnu.org>
* io/transfer.c (read_sf_internal): Remove stray function declaration
- used during debigging.
+ used during debugging.
2010-03-17 Jerry DeLisle <jvdelisle@gcc.gnu.org>
diff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c
index c36b9e5fa69..cd44c04251e 100644
--- a/libgfortran/io/inquire.c
+++ b/libgfortran/io/inquire.c
@@ -371,6 +371,14 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit * u)
cf_strcpy (iqp->round, iqp->round_len, p);
}
+
+ if ((cf2 & IOPARM_INQUIRE_HAS_SIZE) != 0)
+ {
+ if (u == NULL)
+ *iqp->size = -1;
+ else
+ *iqp->size = file_size (u->file, (gfc_charlen_type) u->file_len);
+ }
}
if ((cf & IOPARM_INQUIRE_HAS_POSITION) != 0)
@@ -601,6 +609,9 @@ inquire_via_filename (st_parameter_inquire *iqp)
if ((cf2 & IOPARM_INQUIRE_HAS_ENCODING) != 0)
cf_strcpy (iqp->encoding, iqp->encoding_len, undefined);
+
+ if ((cf2 & IOPARM_INQUIRE_HAS_SIZE) != 0)
+ *iqp->size = file_size (iqp->file, iqp->file_len);
}
if ((cf & IOPARM_INQUIRE_HAS_POSITION) != 0)
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index bd2b6594d52..4435674b46d 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1475,6 +1475,22 @@ file_exists (const char *file, gfc_charlen_type file_len)
}
+/* file_size()-- Returns the size of the file. */
+
+GFC_IO_INT
+file_size (const char *file, gfc_charlen_type file_len)
+{
+ char path[PATH_MAX + 1];
+ gfstat_t statbuf;
+
+ if (unpack_filename (path, file, file_len))
+ return -1;
+
+ if (stat (path, &statbuf) < 0)
+ return -1;
+
+ return (GFC_IO_INT) statbuf.st_size;
+}
static const char yes[] = "YES", no[] = "NO", unknown[] = "UNKNOWN";
diff --git a/libgfortran/io/unix.h b/libgfortran/io/unix.h
index e691982e505..e567fdfe205 100644
--- a/libgfortran/io/unix.h
+++ b/libgfortran/io/unix.h
@@ -121,6 +121,9 @@ internal_proto(delete_file);
extern int file_exists (const char *file, gfc_charlen_type file_len);
internal_proto(file_exists);
+extern GFC_IO_INT file_size (const char *file, gfc_charlen_type file_len);
+internal_proto(file_size);
+
extern const char *inquire_sequential (const char *, int);
internal_proto(inquire_sequential);