2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libf2c / libI77 / rsfe.c
blob0dcda392ce0ae952d0139f1f670752de24f1f016
1 /* read sequential formatted external */
2 #include "config.h"
3 #include "f2c.h"
4 #include "fio.h"
5 #include "fmt.h"
7 int
8 xrd_SL (void)
10 int ch;
11 if (!f__curunit->uend)
12 while ((ch = getc (f__cf)) != '\n')
13 if (ch == EOF)
15 f__curunit->uend = 1;
16 break;
18 f__cursor = f__recpos = 0;
19 return (1);
22 int
23 x_getc (void)
25 int ch;
26 if (f__curunit->uend)
27 return (EOF);
28 ch = getc (f__cf);
29 if (ch != EOF && ch != '\n')
31 f__recpos++;
32 return (ch);
34 if (ch == '\n')
36 (void) ungetc (ch, f__cf);
37 return (ch);
39 if (f__curunit->uend || feof (f__cf))
41 errno = 0;
42 f__curunit->uend = 1;
43 return (-1);
45 return (-1);
48 int
49 x_endp (void)
51 xrd_SL ();
52 return f__curunit->uend == 1 ? EOF : 0;
55 int
56 x_rev (void)
58 (void) xrd_SL ();
59 return (0);
62 integer
63 s_rsfe (cilist * a) /* start */
65 int n;
66 if (f__init != 1)
67 f_init ();
68 f__init = 3;
69 f__reading = 1;
70 f__sequential = 1;
71 f__formatted = 1;
72 f__external = 1;
73 if ((n = c_sfe (a)))
74 return (n);
75 f__elist = a;
76 f__cursor = f__recpos = 0;
77 f__scale = 0;
78 f__fmtbuf = a->cifmt;
79 f__curunit = &f__units[a->ciunit];
80 f__cf = f__curunit->ufd;
81 if (pars_f (f__fmtbuf) < 0)
82 err (a->cierr, 100, "startio");
83 f__getn = x_getc;
84 f__doed = rd_ed;
85 f__doned = rd_ned;
86 fmt_bg ();
87 f__doend = x_endp;
88 f__donewrec = xrd_SL;
89 f__dorevert = x_rev;
90 f__cblank = f__curunit->ublnk;
91 f__cplus = 0;
92 if (f__curunit->uwrt && f__nowreading (f__curunit))
93 err (a->cierr, errno, "read start");
94 if (f__curunit->uend)
95 err (f__elist->ciend, (EOF), "read start");
96 return (0);