FSF GCC merge 02/23/03
[official-gcc.git] / libf2c / libI77 / wsfe.c
blob46f7a8ffef00544079886b32ce0cff2a3d7a7c04
1 /*write sequential formatted external*/
2 #include "config.h"
3 #include "f2c.h"
4 #include "fio.h"
5 #include "fmt.h"
6 extern int f__hiwater;
8 int
9 x_wSL (void)
11 int n = f__putbuf ('\n');
12 f__hiwater = f__recpos = f__cursor = 0;
13 return (n == 0);
16 static int
17 xw_end (void)
19 int n;
21 if (f__nonl)
23 f__putbuf (n = 0);
24 fflush (f__cf);
26 else
27 n = f__putbuf ('\n');
28 f__hiwater = f__recpos = f__cursor = 0;
29 return n;
32 static int
33 xw_rev (void)
35 int n = 0;
36 if (f__workdone)
38 n = f__putbuf ('\n');
39 f__workdone = 0;
41 f__hiwater = f__recpos = f__cursor = 0;
42 return n;
45 integer
46 s_wsfe (cilist * a) /*start */
48 int n;
49 if (f__init != 1)
50 f_init ();
51 f__init = 3;
52 f__reading = 0;
53 f__sequential = 1;
54 f__formatted = 1;
55 f__external = 1;
56 if ((n = c_sfe (a)))
57 return (n);
58 f__elist = a;
59 f__hiwater = f__cursor = f__recpos = 0;
60 f__nonl = 0;
61 f__scale = 0;
62 f__fmtbuf = a->cifmt;
63 f__curunit = &f__units[a->ciunit];
64 f__cf = f__curunit->ufd;
65 if (pars_f (f__fmtbuf) < 0)
66 err (a->cierr, 100, "startio");
67 f__putn = x_putc;
68 f__doed = w_ed;
69 f__doned = w_ned;
70 f__doend = xw_end;
71 f__dorevert = xw_rev;
72 f__donewrec = x_wSL;
73 fmt_bg ();
74 f__cplus = 0;
75 f__cblank = f__curunit->ublnk;
76 if (f__curunit->uwrt != 1 && f__nowwriting (f__curunit))
77 err (a->cierr, errno, "write start");
78 return (0);