re PR fortran/43409 (I/O: INQUIRE for SIZE does not work.)

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.

From-SVN: r157593
This commit is contained in:
Jerry DeLisle 2010-03-20 14:39:00 +00:00
parent d491d2af31
commit 41c3cddc6b
6 changed files with 46 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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>

View File

@ -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)

View File

@ -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";

View File

@ -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);