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