| 1 |
/* read sequential formatted external */ |
| 2 |
#include "f2c.h" |
| 3 |
#include "fio.h" |
| 4 |
#include "fmt.h" |
| 5 |
#ifdef __cplusplus |
| 6 |
extern "C" { |
| 7 |
#endif |
| 8 |
|
| 9 |
int |
| 10 |
xrd_SL(Void) |
| 11 |
{ int ch; |
| 12 |
if(!f__curunit->uend) |
| 13 |
while((ch=getc(f__cf))!='\n') |
| 14 |
if (ch == EOF) { |
| 15 |
f__curunit->uend = 1; |
| 16 |
break; |
| 17 |
} |
| 18 |
f__cursor=f__recpos=0; |
| 19 |
return(1); |
| 20 |
} |
| 21 |
|
| 22 |
int |
| 23 |
x_getc(Void) |
| 24 |
{ int ch; |
| 25 |
if(f__curunit->uend) return(EOF); |
| 26 |
ch = getc(f__cf); |
| 27 |
if(ch!=EOF && ch!='\n') |
| 28 |
{ f__recpos++; |
| 29 |
return(ch); |
| 30 |
} |
| 31 |
if(ch=='\n') |
| 32 |
{ (void) ungetc(ch,f__cf); |
| 33 |
return(ch); |
| 34 |
} |
| 35 |
if(f__curunit->uend || feof(f__cf)) |
| 36 |
{ errno=0; |
| 37 |
f__curunit->uend=1; |
| 38 |
return(-1); |
| 39 |
} |
| 40 |
return(-1); |
| 41 |
} |
| 42 |
|
| 43 |
int |
| 44 |
x_endp(Void) |
| 45 |
{ |
| 46 |
xrd_SL(); |
| 47 |
return f__curunit->uend == 1 ? EOF : 0; |
| 48 |
} |
| 49 |
|
| 50 |
int |
| 51 |
x_rev(Void) |
| 52 |
{ |
| 53 |
(void) xrd_SL(); |
| 54 |
return(0); |
| 55 |
} |
| 56 |
#ifdef KR_headers |
| 57 |
integer s_rsfe(a) cilist *a; /* start */ |
| 58 |
#else |
| 59 |
integer s_rsfe(cilist *a) /* start */ |
| 60 |
#endif |
| 61 |
{ int n; |
| 62 |
if(!f__init) f_init(); |
| 63 |
f__reading=1; |
| 64 |
f__sequential=1; |
| 65 |
f__formatted=1; |
| 66 |
f__external=1; |
| 67 |
if(n=c_sfe(a)) return(n); |
| 68 |
f__elist=a; |
| 69 |
f__cursor=f__recpos=0; |
| 70 |
f__scale=0; |
| 71 |
f__fmtbuf=a->cifmt; |
| 72 |
f__cf=f__curunit->ufd; |
| 73 |
if(pars_f(f__fmtbuf)<0) err(a->cierr,100,"startio"); |
| 74 |
f__getn= x_getc; |
| 75 |
f__doed= rd_ed; |
| 76 |
f__doned= rd_ned; |
| 77 |
fmt_bg(); |
| 78 |
f__doend=x_endp; |
| 79 |
f__donewrec=xrd_SL; |
| 80 |
f__dorevert=x_rev; |
| 81 |
f__cblank=f__curunit->ublnk; |
| 82 |
f__cplus=0; |
| 83 |
if(f__curunit->uwrt && f__nowreading(f__curunit)) |
| 84 |
err(a->cierr,errno,"read start"); |
| 85 |
if(f__curunit->uend) |
| 86 |
err(f__elist->ciend,(EOF),"read start"); |
| 87 |
return(0); |
| 88 |
} |
| 89 |
#ifdef __cplusplus |
| 90 |
} |
| 91 |
#endif |