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