1*779fc935Sceastha /*
2*779fc935Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3*779fc935Sceastha * Use is subject to license terms.
4*779fc935Sceastha */
5*779fc935Sceastha
67c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
77c478bd9Sstevel@tonic-gate /* All Rights Reserved */
87c478bd9Sstevel@tonic-gate
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate */
147c478bd9Sstevel@tonic-gate
15*779fc935Sceastha #pragma ident "%Z%%M% %I% %E% SMI"
167c478bd9Sstevel@tonic-gate
177c478bd9Sstevel@tonic-gate #include "e.h"
187c478bd9Sstevel@tonic-gate
19*779fc935Sceastha void
column(int type,int p1)20*779fc935Sceastha column(int type, int p1)
21*779fc935Sceastha {
227c478bd9Sstevel@tonic-gate int i;
237c478bd9Sstevel@tonic-gate
247c478bd9Sstevel@tonic-gate lp[p1] = ct - p1 - 1;
257c478bd9Sstevel@tonic-gate if (dbg) {
267c478bd9Sstevel@tonic-gate printf(".\t%d column of", type);
277c478bd9Sstevel@tonic-gate for (i = p1 + 1; i < ct; i++)
287c478bd9Sstevel@tonic-gate printf(" S%d", lp[i]);
297c478bd9Sstevel@tonic-gate printf(", rows=%d\n", lp[p1]);
307c478bd9Sstevel@tonic-gate }
317c478bd9Sstevel@tonic-gate lp[ct++] = type;
327c478bd9Sstevel@tonic-gate }
337c478bd9Sstevel@tonic-gate
34*779fc935Sceastha void
matrix(int p1)35*779fc935Sceastha matrix(int p1)
36*779fc935Sceastha {
377c478bd9Sstevel@tonic-gate int nrow, ncol, i, j, k, hb, b, val[100];
387c478bd9Sstevel@tonic-gate char *space;
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate space = "\\ \\ ";
417c478bd9Sstevel@tonic-gate nrow = lp[p1]; /* disaster if rows inconsistent */
427c478bd9Sstevel@tonic-gate ncol = 0;
437c478bd9Sstevel@tonic-gate for (i = p1; i < ct; i += lp[i] + 2) {
447c478bd9Sstevel@tonic-gate ncol++;
457c478bd9Sstevel@tonic-gate if (dbg) printf(".\tcolct=%d\n", lp[i]);
467c478bd9Sstevel@tonic-gate }
477c478bd9Sstevel@tonic-gate for (k = 1; k <= nrow; k++) {
487c478bd9Sstevel@tonic-gate hb = b = 0;
497c478bd9Sstevel@tonic-gate j = p1 + k;
507c478bd9Sstevel@tonic-gate for (i = 0; i < ncol; i++) {
517c478bd9Sstevel@tonic-gate hb = max(hb, eht[lp[j]]-ebase[lp[j]]);
527c478bd9Sstevel@tonic-gate b = max(b, ebase[lp[j]]);
537c478bd9Sstevel@tonic-gate j += nrow + 2;
547c478bd9Sstevel@tonic-gate }
557c478bd9Sstevel@tonic-gate if (dbg) printf(".\trow %d: b=%d, hb=%d\n", k, b, hb);
567c478bd9Sstevel@tonic-gate j = p1 + k;
577c478bd9Sstevel@tonic-gate for (i = 0; i < ncol; i++) {
587c478bd9Sstevel@tonic-gate ebase[lp[j]] = b;
597c478bd9Sstevel@tonic-gate eht[lp[j]] = b + hb;
607c478bd9Sstevel@tonic-gate j += nrow + 2;
617c478bd9Sstevel@tonic-gate }
627c478bd9Sstevel@tonic-gate }
637c478bd9Sstevel@tonic-gate j = p1;
647c478bd9Sstevel@tonic-gate for (i = 0; i < ncol; i++) {
657c478bd9Sstevel@tonic-gate lpile(lp[j+lp[j]+1], j+1, j+lp[j]+1);
667c478bd9Sstevel@tonic-gate val[i] = yyval;
677c478bd9Sstevel@tonic-gate j += nrow + 2;
687c478bd9Sstevel@tonic-gate }
697c478bd9Sstevel@tonic-gate yyval = oalloc();
707c478bd9Sstevel@tonic-gate eht[yyval] = eht[val[0]];
717c478bd9Sstevel@tonic-gate ebase[yyval] = ebase[val[0]];
727c478bd9Sstevel@tonic-gate lfont[yyval] = rfont[yyval] = 0;
73*779fc935Sceastha if (dbg)
74*779fc935Sceastha printf(".\tmatrix S%d: r=%d, c=%d, h=%d, b=%d\n",
757c478bd9Sstevel@tonic-gate yyval, nrow, ncol, eht[yyval], ebase[yyval]);
767c478bd9Sstevel@tonic-gate printf(".ds %d \"", yyval);
777c478bd9Sstevel@tonic-gate for (i = 0; i < ncol; i++) {
787c478bd9Sstevel@tonic-gate printf("\\*(%d%s", val[i], i == ncol-1 ? "" : space);
797c478bd9Sstevel@tonic-gate ofree(val[i]);
807c478bd9Sstevel@tonic-gate }
817c478bd9Sstevel@tonic-gate printf("\n");
827c478bd9Sstevel@tonic-gate ct = p1;
837c478bd9Sstevel@tonic-gate }
84