summaryrefslogtreecommitdiffstats
path: root/contrib/libf2c/libI77/endfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libf2c/libI77/endfile.c')
-rw-r--r--contrib/libf2c/libI77/endfile.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/contrib/libf2c/libI77/endfile.c b/contrib/libf2c/libI77/endfile.c
index 980c91d..4c5a9dd 100644
--- a/contrib/libf2c/libI77/endfile.c
+++ b/contrib/libf2c/libI77/endfile.c
@@ -70,7 +70,7 @@ t_runc(a) alist *a;
t_runc(alist *a)
#endif
{
- long loc, len;
+ off_t loc, len;
unit *b;
int rc;
FILE *bf;
@@ -81,9 +81,9 @@ t_runc(alist *a)
b = &f__units[a->aunit];
if(b->url)
return(0); /*don't truncate direct files*/
- loc=ftell(bf = b->ufd);
- fseek(bf,0L,SEEK_END);
- len=ftell(bf);
+ loc=FTELL(bf = b->ufd);
+ FSEEK(bf,0,SEEK_END);
+ len=FTELL(bf);
if (loc >= len || b->useek == 0 || b->ufnm == NULL)
return(0);
#ifndef HAVE_FTRUNCATE
@@ -111,7 +111,7 @@ t_runc(alist *a)
}
if (!(bf = freopen(b->ufnm, f__w_mode[0], bf)))
goto bad1;
- rewind(tf);
+ FSEEK(tf, 0, SEEK_SET);
if (copy(tf, loc, bf))
goto bad1;
b->uwrt = 1;
@@ -121,7 +121,7 @@ t_runc(alist *a)
fclose(bf);
if (!(bf = fopen(b->ufnm, f__w_mode[3])))
goto bad;
- fseek(bf,0L,SEEK_END);
+ FSEEK(bf,0,SEEK_END);
b->urw = 3;
}
#endif
@@ -131,7 +131,8 @@ done:
f__cf = b->ufd = bf;
#else /* !defined(HAVE_FTRUNCATE) */
fflush(b->ufd);
- rc = ftruncate(fileno(b->ufd), (off_t)loc);
+ rc = ftruncate(fileno(b->ufd), loc);
+ FSEEK(bf,loc,SEEK_SET);
#endif /* !defined(HAVE_FTRUNCATE) */
if (rc)
err(a->aerr,111,"endfile");
OpenPOWER on IntegriCloud