position. */
static void
-skip_record (st_parameter_dt *dtp, ssize_t bytes)
+skip_record (st_parameter_dt *dtp, gfc_offset bytes)
{
ssize_t rlength, readb;
#define MAX_READ 4096
next_record_r (st_parameter_dt *dtp, int done)
{
gfc_offset record;
- int bytes_left;
char p;
int cc;
}
else
{
- bytes_left = (int) dtp->u.p.current_unit->bytes_left;
+ gfc_offset bytes_left = dtp->u.p.current_unit->bytes_left;
bytes_left = min_off (bytes_left,
ssize (dtp->u.p.current_unit->s)
- stell (dtp->u.p.current_unit->s));
/* Utility function like memset() but operating on streams. Return
value is same as for POSIX write(). */
-static ssize_t
-sset (stream *s, int c, ssize_t nbyte)
+static gfc_offset
+sset (stream *s, int c, gfc_offset nbyte)
{
#define WRITE_CHUNK 256
char p[WRITE_CHUNK];
- ssize_t bytes_left, trans;
+ gfc_offset bytes_left;
+ ssize_t trans;
if (nbyte < WRITE_CHUNK)
memset (p, c, nbyte);
static void
next_record_w (st_parameter_dt *dtp, int done)
{
- gfc_offset m, record, max_pos;
- int length;
+ gfc_offset max_pos_off;
/* Zero counters for X- and T-editing. */
- max_pos = dtp->u.p.max_pos;
+ max_pos_off = dtp->u.p.max_pos;
dtp->u.p.max_pos = dtp->u.p.skips = dtp->u.p.pending_spaces = 0;
switch (current_mode (dtp))
case UNFORMATTED_DIRECT:
if (dtp->u.p.current_unit->bytes_left > 0)
{
- length = (int) dtp->u.p.current_unit->bytes_left;
+ gfc_offset length = dtp->u.p.current_unit->bytes_left;
if (sset (dtp->u.p.current_unit->s, 0, length) != length)
goto io_error;
}
if (is_internal_unit (dtp))
{
char *p;
+ /* Internal unit, so must fit in memory. */
+ ptrdiff_t length, m, record;
+ ptrdiff_t max_pos = max_pos_off;
if (is_array_io (dtp))
{
int finished;
- length = (int) dtp->u.p.current_unit->bytes_left;
+ length = dtp->u.p.current_unit->bytes_left;
/* If the farthest position reached is greater than current
position, adjust the position and set length to pad out
- dtp->u.p.current_unit->bytes_left;
if (max_pos > m)
{
- length = (int) (max_pos - m);
+ length = (max_pos - m);
if (sseek (dtp->u.p.current_unit->s,
length, SEEK_CUR) < 0)
{
generate_error (&dtp->common, LIBERROR_INTERNAL_UNIT, NULL);
return;
}
- length = (int) (dtp->u.p.current_unit->recl - max_pos);
+ length = ((ptrdiff_t) dtp->u.p.current_unit->recl - max_pos);
}
p = write_block (dtp, length);
dtp->u.p.current_unit->endfile = AT_ENDFILE;
/* Now seek to this record */
- record = record * dtp->u.p.current_unit->recl;
+ record = record * ((ptrdiff_t) dtp->u.p.current_unit->recl);
if (sseek (dtp->u.p.current_unit->s, record, SEEK_SET) < 0)
{
- dtp->u.p.current_unit->bytes_left;
if (max_pos > m)
{
- length = (int) (max_pos - m);
+ length = max_pos - m;
if (sseek (dtp->u.p.current_unit->s,
length, SEEK_CUR) < 0)
{
generate_error (&dtp->common, LIBERROR_INTERNAL_UNIT, NULL);
return;
}
- length = (int) (dtp->u.p.current_unit->recl - max_pos);
+ length = (ptrdiff_t) dtp->u.p.current_unit->recl
+ - max_pos;
}
else
- length = (int) dtp->u.p.current_unit->bytes_left;
+ length = dtp->u.p.current_unit->bytes_left;
}
if (length > 0)
{