/*Copyright (C) 1992, 1994 by Thomas Glen Smith. All Rights Reserved.*/
/* formatf APL2 V1.0.0 *************************************************
* Called from formatm to fill in f-notation widths. *
***********************************************************************/
#define INCLUDES APLCB+FORM
#include "includes.h"
int formatf(rite,cba)
Aplcb rite,cba;
{
int *cp,d,*dp,i,j,*pp,*sp,*wp,u,wc,wn;
cp = Chrcb;
dp = Digicb;
pp = Precb;
wp = Widcb;
sp = Signcb;
for(i = *(cba->apldim + 1) - 1; i > -1; i--)
if ((*(wp + i) == 0) /* Width specified is zero, and */
&& (0 <= (j = *(pp + i)))) { /* precision specified >= zero. */
d = *(dp + i); /* digits left of d.p. */
wn = 1 /* 1 for intervening blank */
+ *(sp + i) /* 1 for sign */
+ d /* plus digits left of d.p. */
+ (0 == d && j > 0) /* force units pos. if dec. pl. */
+ (j > 0) /* plus d.p. if there is one. */
+j; /* plus places right of d.p. */
wc = 1 + *(cp + i); /* Maximum char length in col. */
*(wp + i) = (wc > wn) ? wc : wn; /* Set column width. */
}
}