mirror of
git://gcc.gnu.org/git/gcc.git
synced 2024-12-28 09:55:12 +08:00
5cad287eff
* libI77/backspace.c: Include "config.h". * libI77/close.c: Likewise. * libI77/dfe.c: Likewise. * libI77/dolio.c: Likewise. * libI77/due.c: Likewise. * libI77/err.c: Likewise. * libI77/fmt.c: Likewise. * libI77/fmtlib.c: Likewise. * libI77/ftell_.c: Likewise. * libI77/ilnw.c: Likewise. * libI77/lread.c: Likewise. * libI77/open.c: Likewise. * libI77/rdfmt.c: Likewise. * libI77/rsfe.c: Likewise. * libI77/rsne.c: Likewise. * libI77/util.c: Likewise. * libI77/wrtfmt.c: Likewise. * libI77/wsne.c: Likewise. * libI77/xwsne.c: Likewise. * libI77/config.h.in: Generate with autoheader. * libI77/configure.in: Add comments for all AC_DEFINES so that autoheader can grok it. * libI77/configure: Regenerated. From-SVN: r42162
75 lines
1.3 KiB
C
75 lines
1.3 KiB
C
#include "config.h"
|
|
#include <sys/types.h>
|
|
#include "f2c.h"
|
|
#include "fio.h"
|
|
#ifdef KR_headers
|
|
integer f_back(a) alist *a;
|
|
#else
|
|
integer f_back(alist *a)
|
|
#endif
|
|
{ unit *b;
|
|
long v, w, x, y, z;
|
|
uiolen n;
|
|
FILE *f;
|
|
|
|
f__curunit = b = &f__units[a->aunit]; /* curunit for error messages */
|
|
if (f__init & 2)
|
|
f__fatal (131, "I/O recursion");
|
|
if(a->aunit >= MXUNIT || a->aunit < 0)
|
|
err(a->aerr,101,"backspace");
|
|
if(b->useek==0) err(a->aerr,106,"backspace");
|
|
if(b->ufd == NULL) {
|
|
fk_open(1, 1, a->aunit);
|
|
return(0);
|
|
}
|
|
if(b->uend==1)
|
|
{ b->uend=0;
|
|
return(0);
|
|
}
|
|
if(b->uwrt) {
|
|
t_runc(a);
|
|
if (f__nowreading(b))
|
|
err(a->aerr,errno,"backspace");
|
|
}
|
|
f = b->ufd; /* may have changed in t_runc() */
|
|
if(b->url>0)
|
|
{
|
|
x=ftell(f);
|
|
y = x % b->url;
|
|
if(y == 0) x--;
|
|
x /= b->url;
|
|
x *= b->url;
|
|
(void) fseek(f,x,SEEK_SET);
|
|
return(0);
|
|
}
|
|
|
|
if(b->ufmt==0)
|
|
{ fseek(f,-(long)sizeof(uiolen),SEEK_CUR);
|
|
fread((char *)&n,sizeof(uiolen),1,f);
|
|
fseek(f,-(long)n-2*sizeof(uiolen),SEEK_CUR);
|
|
return(0);
|
|
}
|
|
w = x = ftell(f);
|
|
z = 0;
|
|
loop:
|
|
while(x) {
|
|
x -= x < 64 ? x : 64;
|
|
fseek(f,x,SEEK_SET);
|
|
for(y = x; y < w; y++) {
|
|
if (getc(f) != '\n')
|
|
continue;
|
|
v = ftell(f);
|
|
if (v == w) {
|
|
if (z)
|
|
goto break2;
|
|
goto loop;
|
|
}
|
|
z = v;
|
|
}
|
|
err(a->aerr,(EOF),"backspace");
|
|
}
|
|
break2:
|
|
fseek(f, z, SEEK_SET);
|
|
return 0;
|
|
}
|