source: branches/libc-0.6/src/gcc/libf2c/libI77/iio.c

Last change on this file was 1392, checked in by bird, 21 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#include "f2c.h"
2#include "fio.h"
3#include "fmt.h"
4extern char *f__icptr;
5char *f__icend;
6extern icilist *f__svic;
7int f__icnum;
8extern int f__hiwater;
9int
10z_getc (void)
11{
12 if (f__recpos++ < f__svic->icirlen)
13 {
14 if (f__icptr >= f__icend)
15 err (f__svic->iciend, (EOF), "endfile");
16 return (*(unsigned char *) f__icptr++);
17 }
18 return '\n';
19}
20
21void
22z_putc (int c)
23{
24 if (f__recpos++ < f__svic->icirlen && f__icptr < f__icend)
25 *f__icptr++ = c;
26}
27int
28z_rnew (void)
29{
30 f__icptr = f__svic->iciunit + (++f__icnum) * f__svic->icirlen;
31 f__recpos = 0;
32 f__cursor = 0;
33 f__hiwater = 0;
34 return 1;
35}
36
37static int
38z_endp (void)
39{
40 (*f__donewrec) ();
41 return 0;
42}
43
44int
45c_si (icilist * a)
46{
47 if (f__init & 2)
48 f__fatal (131, "I/O recursion");
49 f__init |= 2;
50 f__elist = (cilist *) a;
51 f__fmtbuf = a->icifmt;
52 f__curunit = 0;
53 f__sequential = f__formatted = 1;
54 f__external = 0;
55 if (pars_f (f__fmtbuf) < 0)
56 err (a->icierr, 100, "startint");
57 fmt_bg ();
58 f__cblank = f__cplus = f__scale = 0;
59 f__svic = a;
60 f__icnum = f__recpos = 0;
61 f__cursor = 0;
62 f__hiwater = 0;
63 f__icptr = a->iciunit;
64 f__icend = f__icptr + a->icirlen * a->icirnum;
65 f__cf = 0;
66 return (0);
67}
68
69int
70iw_rev (void)
71{
72 if (f__workdone)
73 z_endp ();
74 f__hiwater = f__recpos = f__cursor = 0;
75 return (f__workdone = 0);
76}
77
78integer
79s_rsfi (icilist * a)
80{
81 int n;
82 if ((n = c_si (a)))
83 return (n);
84 f__reading = 1;
85 f__doed = rd_ed;
86 f__doned = rd_ned;
87 f__getn = z_getc;
88 f__dorevert = z_endp;
89 f__donewrec = z_rnew;
90 f__doend = z_endp;
91 return (0);
92}
93
94int
95z_wnew (void)
96{
97 if (f__recpos < f__hiwater)
98 {
99 f__icptr += f__hiwater - f__recpos;
100 f__recpos = f__hiwater;
101 }
102 while (f__recpos++ < f__svic->icirlen)
103 *f__icptr++ = ' ';
104 f__recpos = 0;
105 f__cursor = 0;
106 f__hiwater = 0;
107 f__icnum++;
108 return 1;
109}
110
111integer
112s_wsfi (icilist * a)
113{
114 int n;
115 if ((n = c_si (a)))
116 return (n);
117 f__reading = 0;
118 f__doed = w_ed;
119 f__doned = w_ned;
120 f__putn = z_putc;
121 f__dorevert = iw_rev;
122 f__donewrec = z_wnew;
123 f__doend = z_endp;
124 return (0);
125}
126
127integer
128e_rsfi (void)
129{
130 int n;
131 f__init &= ~2;
132 n = en_fio ();
133 f__fmtbuf = NULL;
134 return (n);
135}
136
137integer
138e_wsfi (void)
139{
140 int n;
141 f__init &= ~2;
142 n = en_fio ();
143 f__fmtbuf = NULL;
144 if (f__svic->icirnum != 1
145 && (f__icnum > f__svic->icirnum
146 || (f__icnum == f__svic->icirnum && (f__recpos | f__hiwater))))
147 err (f__svic->icierr, 110, "inwrite");
148 if (f__recpos < f__hiwater)
149 f__recpos = f__hiwater;
150 if (f__recpos >= f__svic->icirlen)
151 err (f__svic->icierr, 110, "recend");
152 if (!f__recpos && f__icnum)
153 return n;
154 while (f__recpos++ < f__svic->icirlen)
155 *f__icptr++ = ' ';
156 return n;
157}
Note: See TracBrowser for help on using the repository browser.