1 #include "e.h"
2
startcol(int type)3 startcol(int type) /* mark start of column in lp[] array */
4 {
5 int oct = ct;
6
7 lp[ct++] = type;
8 lp[ct++] = 0; /* count, to come */
9 lp[ct++] = 0; /* separation, to come */
10 return oct;
11 }
12
column(int oct,int sep)13 void column(int oct, int sep) /* remember end of column that started at lp[oct] */
14 {
15 int i, type;
16
17 lp[oct+1] = ct - oct - 3;
18 lp[oct+2] = sep;
19 type = lp[oct];
20 if (dbg) {
21 printf(".\t%d column of", type);
22 for (i = oct+3; i < ct; i++ )
23 printf(" S%d", lp[i]);
24 printf(", rows=%d, sep=%d\n", lp[oct+1], lp[oct+2]);
25 }
26 }
27
matrix(int oct)28 void matrix(int oct) /* matrix is list of columns */
29 {
30 int nrow, ncol, i, j, k, val[100];
31 double b, hb;
32 char *space;
33 extern char *Matspace;
34
35 space = Matspace; /* between columns of matrix */
36 nrow = lp[oct+1]; /* disaster if rows inconsistent */
37 /* also assumes just columns */
38 /* fix when add other things */
39 ncol = 0;
40 for (i = oct+1; i < ct; i += lp[i]+3 ) {
41 ncol++;
42 dprintf(".\tcolct=%d\n", lp[i]);
43 }
44 for (k=1; k <= nrow; k++) {
45 hb = b = 0;
46 j = oct + k + 2;
47 for (i=0; i < ncol; i++) {
48 hb = max(hb, eht[lp[j]]-ebase[lp[j]]);
49 b = max(b, ebase[lp[j]]);
50 j += nrow + 3;
51 }
52 dprintf(".\trow %d: b=%g, hb=%g\n", k, b, hb);
53 j = oct + k + 2;
54 for (i=0; i<ncol; i++) {
55 ebase[lp[j]] = b;
56 eht[lp[j]] = b + hb;
57 j += nrow + 3;
58 }
59 }
60 j = oct;
61 for (i=0; i<ncol; i++) {
62 pile(j);
63 val[i] = yyval;
64 j += nrow + 3;
65 }
66 yyval = salloc();
67 eht[yyval] = eht[val[0]];
68 ebase[yyval] = ebase[val[0]];
69 lfont[yyval] = rfont[yyval] = 0;
70 dprintf(".\tmatrix S%d: r=%d, c=%d, h=%g, b=%g\n",
71 yyval,nrow,ncol,eht[yyval],ebase[yyval]);
72 printf(".ds %d \"", yyval);
73 for( i=0; i<ncol; i++ ) {
74 printf("\\*(%d%s", val[i], i==ncol-1 ? "" : space);
75 sfree(val[i]);
76 }
77 printf("\n");
78 }
79