+2007-04-28 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/31501
+ * io/list_read.c (next_char): Fix whitespace.
+ * io/io.h: Remove prototypes and define macros for is_array_io,
+ is_stream_io, and is_internal_unit.
+ * io/unit.c (is_array_io), (is_internal_unit), (is_stream_io): Delete
+ these functions.
+ * io/transfer.c (read_sf): Change handling of internal_unit to make a
+ single call to salloc_r and use memcpy to transfer the data.
+
2007-04-27 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/31532
#define sset(s, c, n) ((s)->set)(s, c, n)
+/* Macros for testing what kinds of I/O we are doing. */
+
+#define is_array_io(dtp) ((dtp)->internal_unit_desc)
+
+#define is_internal_unit(dtp) ((dtp)->u.p.unit_is_internal)
+
+#define is_stream_io(dtp) ((dtp)->u.p.current_unit->flags.access == ACCESS_STREAM)
+
/* The array_loop_spec contains the variables for the loops over index ranges
that are encountered. Since the variables can be negative, ssize_t
is used. */
extern void free_internal_unit (st_parameter_dt *);
internal_proto(free_internal_unit);
-extern int is_internal_unit (st_parameter_dt *);
-internal_proto(is_internal_unit);
-
-extern int is_array_io (st_parameter_dt *);
-internal_proto(is_array_io);
-
-extern int is_stream_io (st_parameter_dt *);
-internal_proto(is_stream_io);
-
extern gfc_unit *find_unit (int);
internal_proto(find_unit);
/* Handle the end-of-record and end-of-file conditions for
internal array unit. */
- if (is_array_io(dtp))
+ if (is_array_io (dtp))
{
if (dtp->u.p.at_eof)
longjmp (*dtp->u.p.eof_jump, 1);
if (is_stream_io (dtp))
dtp->u.p.current_unit->strm_pos++;
- if (is_internal_unit(dtp))
+ if (is_internal_unit (dtp))
{
- if (is_array_io(dtp))
+ if (is_array_io (dtp))
{
/* End of record is handled in the next pass through, above. The
check for NULL here is cautionary. */
return base;
}
+ if (is_internal_unit (dtp))
+ {
+ readlen = *length;
+ q = salloc_r (dtp->u.p.current_unit->s, &readlen);
+ memcpy (p, q, readlen);
+ goto done;
+ }
+
readlen = 1;
n = 0;
do
{
- if (is_internal_unit (dtp))
- {
- /* readlen may be modified inside salloc_r if
- is_internal_unit (dtp) is true. */
- readlen = 1;
- }
-
q = salloc_r (dtp->u.p.current_unit->s, &readlen);
if (q == NULL)
break;
dtp->u.p.sf_seen_eor = 0;
}
while (n < *length);
+
+ done:
dtp->u.p.current_unit->bytes_left -= *length;
if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0)
}
-/* is_internal_unit()-- Determine if the current unit is internal or not */
-
-int
-is_internal_unit (st_parameter_dt *dtp)
-{
- return dtp->u.p.unit_is_internal;
-}
-
-
-/* is_array_io ()-- Determine if the I/O is to/from an array */
-
-int
-is_array_io (st_parameter_dt *dtp)
-{
- return dtp->internal_unit_desc != NULL;
-}
-
-
-/* is_stream_io () -- Determine if I/O is access="stream" mode */
-
-int
-is_stream_io (st_parameter_dt *dtp)
-{
- return dtp->u.p.current_unit->flags.access == ACCESS_STREAM;
-}
-
-
/*************************/
/* Initialize everything */