1*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 3*7c478bd9Sstevel@tonic-gate 4*7c478bd9Sstevel@tonic-gate 5*7c478bd9Sstevel@tonic-gate /* 6*7c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 7*7c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 8*7c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 9*7c478bd9Sstevel@tonic-gate */ 10*7c478bd9Sstevel@tonic-gate 11*7c478bd9Sstevel@tonic-gate /* 12*7c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc. 13*7c478bd9Sstevel@tonic-gate * All Rights Reserved. 14*7c478bd9Sstevel@tonic-gate */ 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.1 */ 17*7c478bd9Sstevel@tonic-gate 18*7c478bd9Sstevel@tonic-gate # include "e.h" 19*7c478bd9Sstevel@tonic-gate 20*7c478bd9Sstevel@tonic-gate paren(leftc, p1, rightc) int p1, leftc, rightc; { 21*7c478bd9Sstevel@tonic-gate int n, m, h1, j, b1, v; 22*7c478bd9Sstevel@tonic-gate h1 = eht[p1]; b1 = ebase[p1]; 23*7c478bd9Sstevel@tonic-gate yyval = p1; 24*7c478bd9Sstevel@tonic-gate #ifndef NEQN 25*7c478bd9Sstevel@tonic-gate lfont[yyval] = rfont[yyval] = 0; 26*7c478bd9Sstevel@tonic-gate n = (h1 + EM(1.0, EFFPS(ps)) - 1) / EM(1.0, EFFPS(ps)); 27*7c478bd9Sstevel@tonic-gate #else NEQN 28*7c478bd9Sstevel@tonic-gate n = max(b1+VERT(1), h1-b1-VERT(1)) / VERT(1); 29*7c478bd9Sstevel@tonic-gate #endif NEQN 30*7c478bd9Sstevel@tonic-gate if( n<2 ) n = 1; 31*7c478bd9Sstevel@tonic-gate m = n-2; 32*7c478bd9Sstevel@tonic-gate if (leftc=='{' || rightc == '}') { 33*7c478bd9Sstevel@tonic-gate n = n%2 ? n : ++n; 34*7c478bd9Sstevel@tonic-gate if( n<3 ) n=3; 35*7c478bd9Sstevel@tonic-gate m = n-3; 36*7c478bd9Sstevel@tonic-gate } 37*7c478bd9Sstevel@tonic-gate #ifndef NEQN 38*7c478bd9Sstevel@tonic-gate eht[yyval] = VERT(EM(n, ps)); 39*7c478bd9Sstevel@tonic-gate ebase[yyval] = b1 + (eht[yyval]-h1)/2; 40*7c478bd9Sstevel@tonic-gate v = b1 - h1/2 + VERT(EM(0.4, ps)); 41*7c478bd9Sstevel@tonic-gate #else NEQN 42*7c478bd9Sstevel@tonic-gate eht[yyval] = VERT(2 * n); 43*7c478bd9Sstevel@tonic-gate ebase[yyval] = (n)/2 * VERT(2); 44*7c478bd9Sstevel@tonic-gate if (n%2 == 0) 45*7c478bd9Sstevel@tonic-gate ebase[yyval] -= VERT(1); 46*7c478bd9Sstevel@tonic-gate v = b1 - h1/2 + VERT(1); 47*7c478bd9Sstevel@tonic-gate #endif NEQN 48*7c478bd9Sstevel@tonic-gate printf(".ds %d \\|\\v'%du'", yyval, v); 49*7c478bd9Sstevel@tonic-gate switch( leftc ) { 50*7c478bd9Sstevel@tonic-gate case 'n': /* nothing */ 51*7c478bd9Sstevel@tonic-gate case '\0': 52*7c478bd9Sstevel@tonic-gate break; 53*7c478bd9Sstevel@tonic-gate case 'f': /* floor */ 54*7c478bd9Sstevel@tonic-gate if (n <= 1) 55*7c478bd9Sstevel@tonic-gate printf("\\(lf"); 56*7c478bd9Sstevel@tonic-gate else 57*7c478bd9Sstevel@tonic-gate brack(m, "\\(bv", "\\(bv", "\\(lf"); 58*7c478bd9Sstevel@tonic-gate break; 59*7c478bd9Sstevel@tonic-gate case 'c': /* ceiling */ 60*7c478bd9Sstevel@tonic-gate if (n <= 1) 61*7c478bd9Sstevel@tonic-gate printf("\\(lc"); 62*7c478bd9Sstevel@tonic-gate else 63*7c478bd9Sstevel@tonic-gate brack(m, "\\(lc", "\\(bv", "\\(bv"); 64*7c478bd9Sstevel@tonic-gate break; 65*7c478bd9Sstevel@tonic-gate case '{': 66*7c478bd9Sstevel@tonic-gate printf("\\b'\\(lt"); 67*7c478bd9Sstevel@tonic-gate for(j = 0; j < m; j += 2) printf("\\(bv"); 68*7c478bd9Sstevel@tonic-gate printf("\\(lk"); 69*7c478bd9Sstevel@tonic-gate for(j = 0; j < m; j += 2) printf("\\(bv"); 70*7c478bd9Sstevel@tonic-gate printf("\\(lb'"); 71*7c478bd9Sstevel@tonic-gate break; 72*7c478bd9Sstevel@tonic-gate case '(': 73*7c478bd9Sstevel@tonic-gate brack(m, "\\(lt", "\\(bv", "\\(lb"); 74*7c478bd9Sstevel@tonic-gate break; 75*7c478bd9Sstevel@tonic-gate case '[': 76*7c478bd9Sstevel@tonic-gate brack(m, "\\(lc", "\\(bv", "\\(lf"); 77*7c478bd9Sstevel@tonic-gate break; 78*7c478bd9Sstevel@tonic-gate case '|': 79*7c478bd9Sstevel@tonic-gate brack(m, "\\(bv", "\\(bv", "\\(bv"); 80*7c478bd9Sstevel@tonic-gate break; 81*7c478bd9Sstevel@tonic-gate default: 82*7c478bd9Sstevel@tonic-gate brack(m, (char *) &leftc, (char *) &leftc, (char *) &leftc); 83*7c478bd9Sstevel@tonic-gate break; 84*7c478bd9Sstevel@tonic-gate } 85*7c478bd9Sstevel@tonic-gate printf("\\v'%du'\\*(%d", -v, p1); 86*7c478bd9Sstevel@tonic-gate if( rightc ) { 87*7c478bd9Sstevel@tonic-gate printf("\\|\\v'%du'", v); 88*7c478bd9Sstevel@tonic-gate switch( rightc ) { 89*7c478bd9Sstevel@tonic-gate case 'f': /* floor */ 90*7c478bd9Sstevel@tonic-gate if (n <= 1) 91*7c478bd9Sstevel@tonic-gate printf("\\(rf"); 92*7c478bd9Sstevel@tonic-gate else 93*7c478bd9Sstevel@tonic-gate brack(m, "\\(bv", "\\(bv", "\\(rf"); 94*7c478bd9Sstevel@tonic-gate break; 95*7c478bd9Sstevel@tonic-gate case 'c': /* ceiling */ 96*7c478bd9Sstevel@tonic-gate if (n <= 1) 97*7c478bd9Sstevel@tonic-gate printf("\\(rc"); 98*7c478bd9Sstevel@tonic-gate else 99*7c478bd9Sstevel@tonic-gate brack(m, "\\(rc", "\\(bv", "\\(bv"); 100*7c478bd9Sstevel@tonic-gate break; 101*7c478bd9Sstevel@tonic-gate case '}': 102*7c478bd9Sstevel@tonic-gate printf("\\b'\\(rt"); 103*7c478bd9Sstevel@tonic-gate for(j = 0; j< m; j += 2)printf("\\(bv"); 104*7c478bd9Sstevel@tonic-gate printf("\\(rk"); 105*7c478bd9Sstevel@tonic-gate for(j = 0; j< m; j += 2) printf("\\(bv"); 106*7c478bd9Sstevel@tonic-gate printf("\\(rb'"); 107*7c478bd9Sstevel@tonic-gate break; 108*7c478bd9Sstevel@tonic-gate case ']': 109*7c478bd9Sstevel@tonic-gate brack(m, "\\(rc", "\\(bv", "\\(rf"); 110*7c478bd9Sstevel@tonic-gate break; 111*7c478bd9Sstevel@tonic-gate case ')': 112*7c478bd9Sstevel@tonic-gate brack(m, "\\(rt", "\\(bv", "\\(rb"); 113*7c478bd9Sstevel@tonic-gate break; 114*7c478bd9Sstevel@tonic-gate case '|': 115*7c478bd9Sstevel@tonic-gate brack(m, "\\(bv", "\\(bv", "\\(bv"); 116*7c478bd9Sstevel@tonic-gate break; 117*7c478bd9Sstevel@tonic-gate default: 118*7c478bd9Sstevel@tonic-gate brack(m, (char *) &rightc, (char *) &rightc, (char *) &rightc); 119*7c478bd9Sstevel@tonic-gate break; 120*7c478bd9Sstevel@tonic-gate } 121*7c478bd9Sstevel@tonic-gate printf("\\v'%du'", -v); 122*7c478bd9Sstevel@tonic-gate } 123*7c478bd9Sstevel@tonic-gate printf("\n"); 124*7c478bd9Sstevel@tonic-gate if(dbg)printf(".\tcurly: h=%d b=%d n=%d v=%d l=%c, r=%c\n", 125*7c478bd9Sstevel@tonic-gate eht[yyval], ebase[yyval], n, v, leftc, rightc); 126*7c478bd9Sstevel@tonic-gate } 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate brack(m, t, c, b) int m; char *t, *c, *b; { 129*7c478bd9Sstevel@tonic-gate int j; 130*7c478bd9Sstevel@tonic-gate printf("\\b'%s", t); 131*7c478bd9Sstevel@tonic-gate for( j=0; j<m; j++) 132*7c478bd9Sstevel@tonic-gate printf("%s", c); 133*7c478bd9Sstevel@tonic-gate printf("%s'", b); 134*7c478bd9Sstevel@tonic-gate } 135