1*364Sceastha /*
2*364Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3*364Sceastha * Use is subject to license terms.
4*364Sceastha */
5*364Sceastha
60Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
70Sstevel@tonic-gate /* All Rights Reserved */
80Sstevel@tonic-gate
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California.
110Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement
120Sstevel@tonic-gate * specifies the terms and conditions for redistribution.
130Sstevel@tonic-gate */
14*364Sceastha
15*364Sceastha #pragma ident "%Z%%M% %I% %E% SMI"
160Sstevel@tonic-gate
170Sstevel@tonic-gate #include "e.h"
180Sstevel@tonic-gate
19*364Sceastha void
column(int type,int p1)20*364Sceastha column(int type, int p1)
21*364Sceastha {
220Sstevel@tonic-gate int i;
230Sstevel@tonic-gate
240Sstevel@tonic-gate lp[p1] = ct - p1 - 1;
25*364Sceastha if (dbg) {
260Sstevel@tonic-gate printf(".\t%d column of", type);
27*364Sceastha for (i = p1 + 1; i < ct; i++)
280Sstevel@tonic-gate printf(" S%d", lp[i]);
29*364Sceastha printf(", rows=%d\n", lp[p1]);
300Sstevel@tonic-gate }
310Sstevel@tonic-gate lp[ct++] = type;
320Sstevel@tonic-gate }
330Sstevel@tonic-gate
34*364Sceastha void
matrix(int p1)35*364Sceastha matrix(int p1)
36*364Sceastha {
370Sstevel@tonic-gate int nrow, ncol, i, j, k, hb, b, val[100];
380Sstevel@tonic-gate char *space;
390Sstevel@tonic-gate
400Sstevel@tonic-gate space = "\\ \\ ";
410Sstevel@tonic-gate nrow = lp[p1]; /* disaster if rows inconsistent */
420Sstevel@tonic-gate ncol = 0;
43*364Sceastha for (i = p1; i < ct; i += lp[i] + 2) {
440Sstevel@tonic-gate ncol++;
45*364Sceastha if (dbg) printf(".\tcolct=%d\n", lp[i]);
460Sstevel@tonic-gate }
47*364Sceastha for (k = 1; k <= nrow; k++) {
480Sstevel@tonic-gate hb = b = 0;
490Sstevel@tonic-gate j = p1 + k;
50*364Sceastha for (i = 0; i < ncol; i++) {
510Sstevel@tonic-gate hb = max(hb, eht[lp[j]]-ebase[lp[j]]);
520Sstevel@tonic-gate b = max(b, ebase[lp[j]]);
530Sstevel@tonic-gate j += nrow + 2;
540Sstevel@tonic-gate }
55*364Sceastha if (dbg) printf(".\trow %d: b=%d, hb=%d\n", k, b, hb);
560Sstevel@tonic-gate j = p1 + k;
57*364Sceastha for (i = 0; i < ncol; i++) {
580Sstevel@tonic-gate ebase[lp[j]] = b;
590Sstevel@tonic-gate eht[lp[j]] = b + hb;
600Sstevel@tonic-gate j += nrow + 2;
610Sstevel@tonic-gate }
620Sstevel@tonic-gate }
630Sstevel@tonic-gate j = p1;
64*364Sceastha for (i = 0; i < ncol; i++) {
650Sstevel@tonic-gate lpile(lp[j+lp[j]+1], j+1, j+lp[j]+1);
660Sstevel@tonic-gate val[i] = yyval;
670Sstevel@tonic-gate j += nrow + 2;
680Sstevel@tonic-gate }
690Sstevel@tonic-gate yyval = oalloc();
700Sstevel@tonic-gate eht[yyval] = eht[val[0]];
710Sstevel@tonic-gate ebase[yyval] = ebase[val[0]];
720Sstevel@tonic-gate lfont[yyval] = rfont[yyval] = 0;
73*364Sceastha if (dbg)
74*364Sceastha printf(".\tmatrix S%d: r=%d, c=%d, h=%d, b=%d\n",
75*364Sceastha yyval, nrow, ncol, eht[yyval], ebase[yyval]);
760Sstevel@tonic-gate printf(".ds %d \"", yyval);
77*364Sceastha for (i = 0; i < ncol; i++) {
78*364Sceastha printf("\\*(%d%s", val[i], i == ncol-1 ? "" : space);
790Sstevel@tonic-gate ofree(val[i]);
800Sstevel@tonic-gate }
810Sstevel@tonic-gate printf("\n");
820Sstevel@tonic-gate ct = p1;
830Sstevel@tonic-gate }
84