-/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
Contributed by Andy Vaught
Namelist transfer functions contributed by Paul Thomas
/* Read sequential file - internal unit */
-char *
-read_sf_internal (st_parameter_dt *dtp, int * length);
-char *
+static char *
read_sf_internal (st_parameter_dt *dtp, int * length)
{
static char *empty_string[0];
return;
}
- if (dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL
- && (cf & IOPARM_DT_HAS_REC) != 0)
+ if (dtp->u.p.current_unit->flags.access == ACCESS_SEQUENTIAL)
{
- generate_error (&dtp->common, LIBERROR_OPTION_CONFLICT,
- "Record number not allowed for sequential access "
- "data transfer");
- return;
- }
+ if ((cf & IOPARM_DT_HAS_REC) != 0)
+ {
+ generate_error (&dtp->common, LIBERROR_OPTION_CONFLICT,
+ "Record number not allowed for sequential access "
+ "data transfer");
+ return;
+ }
+
+ if (dtp->u.p.current_unit->endfile == AFTER_ENDFILE)
+ {
+ generate_error (&dtp->common, LIBERROR_OPTION_CONFLICT,
+ "Sequential READ or WRITE not allowed after "
+ "EOF marker, possibly use REWIND or BACKSPACE");
+ return;
+ }
+ }
/* Process the ADVANCE option. */
dtp->u.p.advance_status
{
if (errno != 0)
generate_error (&dtp->common, LIBERROR_OS, NULL);
- else if (dtp->u.p.item_count == 1
- || dtp->u.p.pending_spaces == 0)
- hit_eof (dtp);
+ else
+ {
+ if (is_stream_io (dtp)
+ || dtp->u.p.current_unit->pad_status == PAD_NO
+ || dtp->u.p.current_unit->bytes_left
+ == dtp->u.p.current_unit->recl)
+ hit_eof (dtp);
+ }
break;
}