-/* Copyright (C) 2002, 2003, 2005, 2007, 2009, 2010, 2011
- Free Software Foundation, Inc.
+/* Copyright (C) 2002-2013 Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of the GNU Fortran runtime library (libgfortran).
if (u == NULL)
*iqp->size = -1;
else
- *iqp->size = file_size (u->file, (gfc_charlen_type) u->file_len);
+ {
+ sflush (u->s);
+ *iqp->size = ssize (u->s);
+ }
+ }
+
+ if ((cf2 & IOPARM_INQUIRE_HAS_IQSTREAM) != 0)
+ {
+ if (u == NULL)
+ p = "UNKNOWN";
+ else
+ switch (u->flags.access)
+ {
+ case ACCESS_SEQUENTIAL:
+ case ACCESS_DIRECT:
+ p = "NO";
+ break;
+ case ACCESS_STREAM:
+ p = "YES";
+ break;
+ default:
+ internal_error (&iqp->common, "inquire_via_unit(): Bad pad");
+ }
+
+ cf_strcpy (iqp->iqstream, iqp->iqstream_len, p);
}
}
if (u == NULL || u->flags.access == ACCESS_DIRECT)
p = undefined;
else
- switch (u->flags.position)
- {
- case POSITION_REWIND:
- p = "REWIND";
- break;
- case POSITION_APPEND:
- p = "APPEND";
- break;
- case POSITION_ASIS:
- p = "ASIS";
- break;
- default:
- /* if not direct access, it must be
- either REWIND, APPEND, or ASIS.
- ASIS seems to be the best default */
- p = "ASIS";
- break;
- }
+ {
+ /* If the position is unspecified, check if we can figure
+ out whether it's at the beginning or end. */
+ if (u->flags.position == POSITION_UNSPECIFIED)
+ {
+ gfc_offset cur = stell (u->s);
+ if (cur == 0)
+ u->flags.position = POSITION_REWIND;
+ else if (cur != -1 && (ssize (u->s) == cur))
+ u->flags.position = POSITION_APPEND;
+ }
+ switch (u->flags.position)
+ {
+ case POSITION_REWIND:
+ p = "REWIND";
+ break;
+ case POSITION_APPEND:
+ p = "APPEND";
+ break;
+ case POSITION_ASIS:
+ p = "ASIS";
+ break;
+ default:
+ /* If the position has changed and is not rewind or
+ append, it must be set to a processor-dependent
+ value. */
+ p = "UNSPECIFIED";
+ break;
+ }
+ }
cf_strcpy (iqp->position, iqp->position_len, p);
}
if ((cf2 & IOPARM_INQUIRE_HAS_SIZE) != 0)
*iqp->size = file_size (iqp->file, iqp->file_len);
+
+ if ((cf2 & IOPARM_INQUIRE_HAS_IQSTREAM) != 0)
+ cf_strcpy (iqp->iqstream, iqp->iqstream_len, "UNKNOWN");
}
if ((cf & IOPARM_INQUIRE_HAS_POSITION) != 0)