6 extern icilist
*f__svic
;
10 mv_cur (void) /* shouldn't use fseek because it insists on calling fflush */
11 /* instead we know too much about stdio */
13 int cursor
= f__cursor
;
19 if (f__hiwater
< f__recpos
)
20 f__hiwater
= f__recpos
;
24 err (f__elist
->cierr
, 110, "left off");
28 if (f__recpos
+ cursor
>= f__svic
->icirlen
)
29 err (f__elist
->cierr
, 110, "recend");
30 if (f__hiwater
<= f__recpos
)
31 for (; cursor
> 0; cursor
--)
33 else if (f__hiwater
<= f__recpos
+ cursor
)
35 cursor
-= f__hiwater
- f__recpos
;
36 f__icptr
+= f__hiwater
- f__recpos
;
37 f__recpos
= f__hiwater
;
38 for (; cursor
> 0; cursor
--)
51 if (f__hiwater
<= f__recpos
)
52 for (; cursor
> 0; cursor
--)
54 else if (f__hiwater
<= f__recpos
+ cursor
)
56 cursor
-= f__hiwater
- f__recpos
;
57 f__recpos
= f__hiwater
;
58 for (; cursor
> 0; cursor
--)
68 if (cursor
+ f__recpos
< 0)
69 err (f__elist
->cierr
, 110, "left off");
70 if (f__hiwater
< f__recpos
)
71 f__hiwater
= f__recpos
;
78 wrt_Z (Uint
* n
, int w
, int minlen
, ftnlen len
)
80 register char *s
, *se
;
83 static char hex
[] = "0123456789ABCDEF";
101 w1
= (i
* (se
- s
) << 1) + 1;
105 for (i
= 0; i
< w
; i
++)
109 if ((minlen
-= w1
) > 0)
113 while (--minlen
>= 0)
117 (*f__putn
) (hex
[*s
& 0xf]);
124 (*f__putn
) (hex
[*s
>> 4 & 0xf]);
125 (*f__putn
) (hex
[*s
& 0xf]);
134 wrt_I (Uint
* n
, int w
, ftnlen len
, register int base
)
136 int ndigit
, sign
, spare
, i
;
139 if (len
== sizeof (integer
))
141 else if (len
== sizeof (char))
144 else if (len
== sizeof (longint
))
149 ans
= f__icvt (x
, &ndigit
, &sign
, base
);
151 if (sign
|| f__cplus
)
154 for (i
= 0; i
< w
; i
++)
158 for (i
= 0; i
< spare
; i
++)
164 for (i
= 0; i
< ndigit
; i
++)
170 wrt_IM (Uint
* n
, int w
, int m
, ftnlen len
, int base
)
172 int ndigit
, sign
, spare
, i
, xsign
;
175 if (sizeof (integer
) == len
)
177 else if (len
== sizeof (char))
180 else if (len
== sizeof (longint
))
185 ans
= f__icvt (x
, &ndigit
, &sign
, base
);
186 if (sign
|| f__cplus
)
190 if (ndigit
+ xsign
> w
|| m
+ xsign
> w
)
192 for (i
= 0; i
< w
; i
++)
196 if (x
== 0 && m
== 0)
198 for (i
= 0; i
< w
; i
++)
203 spare
= w
- ndigit
- xsign
;
205 spare
= w
- m
- xsign
;
206 for (i
= 0; i
< spare
; i
++)
212 for (i
= 0; i
< m
- ndigit
; i
++)
214 for (i
= 0; i
< ndigit
; i
++)
224 if (f__cursor
&& (i
= mv_cur ()))
231 else if (*++s
== quote
)
239 wrt_H (int a
, char *s
)
243 if (f__cursor
&& (i
= mv_cur ()))
251 wrt_L (Uint
* n
, int len
, ftnlen sz
)
255 if (sizeof (long) == sz
)
257 else if (sz
== sizeof (char))
261 for (i
= 0; i
< len
- 1; i
++)
270 wrt_A (char *p
, ftnlen len
)
277 wrt_AW (char *p
, int w
, ftnlen len
)
290 wrt_G (ufloat
* p
, int w
, int d
, int e
, ftnlen len
)
293 int i
= 0, oldscale
, n
, j
;
294 x
= len
== sizeof (real
) ? p
->pf
: p
->pd
;
300 return (wrt_E (p
, w
, d
, e
, len
));
304 for (; i
<= d
; i
++, up
*= 10)
315 i
= wrt_F (p
, w
- n
, d
- i
, len
);
316 for (j
= 0; j
< n
; j
++)
321 return (wrt_E (p
, w
, d
, e
, len
));
325 w_ed (struct syl
* p
, char *ptr
, ftnlen len
)
329 if (f__cursor
&& (i
= mv_cur ()))
334 fprintf (stderr
, "w_ed, unexpected code: %d\n", p
->op
);
335 sig_die (f__fmtbuf
, 1);
337 return (wrt_I ((Uint
*) ptr
, p
->p1
, len
, 10));
339 return (wrt_IM ((Uint
*) ptr
, p
->p1
, p
->p2
.i
[0], len
, 10));
341 /* O and OM don't work right for character, double, complex, */
342 /* or doublecomplex, and they differ from Fortran 90 in */
343 /* showing a minus sign for negative values. */
346 return (wrt_I ((Uint
*) ptr
, p
->p1
, len
, 8));
348 return (wrt_IM ((Uint
*) ptr
, p
->p1
, p
->p2
.i
[0], len
, 8));
350 return (wrt_L ((Uint
*) ptr
, p
->p1
, len
));
352 return (wrt_A (ptr
, len
));
354 return (wrt_AW (ptr
, p
->p1
, len
));
358 return (wrt_E ((ufloat
*) ptr
, p
->p1
, p
->p2
.i
[0], p
->p2
.i
[1], len
));
361 return (wrt_G ((ufloat
*) ptr
, p
->p1
, p
->p2
.i
[0], p
->p2
.i
[1], len
));
363 return (wrt_F ((ufloat
*) ptr
, p
->p1
, p
->p2
.i
[0], len
));
365 /* Z and ZM assume 8-bit bytes. */
368 return (wrt_Z ((Uint
*) ptr
, p
->p1
, 0, len
));
370 return (wrt_Z ((Uint
*) ptr
, p
->p1
, p
->p2
.i
[0], len
));
375 w_ned (struct syl
* p
)
380 fprintf (stderr
, "w_ned, unexpected code: %d\n", p
->op
);
381 sig_die (f__fmtbuf
, 1);
383 return ((*f__donewrec
) ());
385 f__cursor
= p
->p1
- f__recpos
- 1;
389 if (f__cursor
< -f__recpos
) /* TL1000, 1X */
390 f__cursor
= -f__recpos
;
397 return (wrt_AP (p
->p2
.s
));
399 return (wrt_H (p
->p1
, p
->p2
.s
));