1 /* 2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 7 /* All Rights Reserved */ 8 9 /* 10 * Copyright (c) 1980 Regents of the University of California. 11 * All rights reserved. The Berkeley software License Agreement 12 * specifies the terms and conditions for redistribution. 13 */ 14 15 #include "e.h" 16 17 void 18 column(int type, int p1) 19 { 20 int i; 21 22 lp[p1] = ct - p1 - 1; 23 if (dbg) { 24 printf(".\t%d column of", type); 25 for (i = p1 + 1; i < ct; i++) 26 printf(" S%d", lp[i]); 27 printf(", rows=%d\n", lp[p1]); 28 } 29 lp[ct++] = type; 30 } 31 32 void 33 matrix(int p1) 34 { 35 int nrow, ncol, i, j, k, hb, b, val[100]; 36 char *space; 37 38 space = "\\ \\ "; 39 nrow = lp[p1]; /* disaster if rows inconsistent */ 40 ncol = 0; 41 for (i = p1; i < ct; i += lp[i] + 2) { 42 ncol++; 43 if (dbg) printf(".\tcolct=%d\n", lp[i]); 44 } 45 for (k = 1; k <= nrow; k++) { 46 hb = b = 0; 47 j = p1 + k; 48 for (i = 0; i < ncol; i++) { 49 hb = max(hb, eht[lp[j]]-ebase[lp[j]]); 50 b = max(b, ebase[lp[j]]); 51 j += nrow + 2; 52 } 53 if (dbg) printf(".\trow %d: b=%d, hb=%d\n", k, b, hb); 54 j = p1 + k; 55 for (i = 0; i < ncol; i++) { 56 ebase[lp[j]] = b; 57 eht[lp[j]] = b + hb; 58 j += nrow + 2; 59 } 60 } 61 j = p1; 62 for (i = 0; i < ncol; i++) { 63 lpile(lp[j+lp[j]+1], j+1, j+lp[j]+1); 64 val[i] = yyval; 65 j += nrow + 2; 66 } 67 yyval = oalloc(); 68 eht[yyval] = eht[val[0]]; 69 ebase[yyval] = ebase[val[0]]; 70 lfont[yyval] = rfont[yyval] = 0; 71 if (dbg) 72 printf(".\tmatrix S%d: r=%d, c=%d, h=%d, b=%d\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 ofree(val[i]); 78 } 79 printf("\n"); 80 ct = p1; 81 } 82