/* $MirOS: src/usr.bin/oldroff/neqn/paren.c,v 1.2 2008/11/08 23:04:37 tg Exp $ */ /*- * Copyright (c) 1979, 1980, 1981, 1986, 1988, 1990, 1991, 1992 * The Regents of the University of California. * Copyright (C) Caldera International Inc. 2001-2002. * Copyright (c) 2003, 2004 * Thorsten "mirabilos" Glaser * All rights reserved. * * Redistribution and use in source and binary forms, * with or without modification, are permitted provided * that the following conditions are met: * * Redistributions of source code and documentation must retain * the above copyright notice, this list of conditions and the * following disclaimer. Redistributions in binary form must * reproduce the above copyright notice, this list of conditions * and the following disclaimer in the documentation and/or other * materials provided with the distribution. * * All advertising materials mentioning features or use of this * software must display the following acknowledgement: * This product includes software developed or owned by * Caldera International, Inc. * * Neither the name of Caldera International, Inc. nor the names * of other contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA * INTERNATIONAL, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef lint static char sccsid[] = "@(#)paren.c 4.4 (Berkeley) 4/17/91"; #endif # include "e.h" paren(leftc, p1, rightc) int p1, leftc, rightc; { int n, m, h1, j, b1, v; h1 = eht[p1]; b1 = ebase[p1]; yyval = p1; #ifndef NEQN lfont[yyval] = rfont[yyval] = 0; n = (h1+(6*EFFPS(ps)-1))/(6*EFFPS(ps)); #else n = max(b1+VERT(1), h1-b1-VERT(1)) / VERT(1); #endif if( n<2 ) n = 1; m = n-2; if (leftc=='{' || rightc == '}') { n = n%2 ? n : ++n; if( n<3 ) n=3; m = n-3; } #ifndef NEQN eht[yyval] = VERT(6 * ps * n); ebase[yyval] = b1 + (eht[yyval]-h1)/2; v = b1 - h1/2 + VERT( (ps*6*4)/10 ); #else eht[yyval] = VERT(2 * n); ebase[yyval] = (n)/2 * VERT(2); if (n%2 == 0) ebase[yyval] -= VERT(1); v = b1 - h1/2 + VERT(1); #endif printf(".ds %d \\|\\v'%du'", yyval, v); switch( leftc ) { case 'n': /* nothing */ case '\0': break; case 'f': /* floor */ if (n <= 1) printf("\\(lf"); else brack(m, "\\(bv", "\\(bv", "\\(lf"); break; case 'c': /* ceiling */ if (n <= 1) printf("\\(lc"); else brack(m, "\\(lc", "\\(bv", "\\(bv"); break; case '{': printf("\\b'\\(lt"); for(j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(lk"); for(j = 0; j < m; j += 2) printf("\\(bv"); printf("\\(lb'"); break; case '(': brack(m, "\\(lt", "\\(bv", "\\(lb"); break; case '[': brack(m, "\\(lc", "\\(bv", "\\(lf"); break; case '|': brack(m, "|", "|", "|"); break; default: brack(m, (char *) &leftc, (char *) &leftc, (char *) &leftc); break; } printf("\\v'%du'\\*(%d", -v, p1); if( rightc ) { printf("\\|\\v'%du'", v); switch( rightc ) { case 'f': /* floor */ if (n <= 1) printf("\\(rf"); else brack(m, "\\(bv", "\\(bv", "\\(rf"); break; case 'c': /* ceiling */ if (n <= 1) printf("\\(rc"); else brack(m, "\\(rc", "\\(bv", "\\(bv"); break; case '}': printf("\\b'\\(rt"); for(j = 0; j< m; j += 2)printf("\\(bv"); printf("\\(rk"); for(j = 0; j< m; j += 2) printf("\\(bv"); printf("\\(rb'"); break; case ']': brack(m, "\\(rc", "\\(bv", "\\(rf"); break; case ')': brack(m, "\\(rt", "\\(bv", "\\(rb"); break; case '|': brack(m, "|", "|", "|"); break; default: brack(m, (char *) &rightc, (char *) &rightc, (char *) &rightc); break; } printf("\\v'%du'", -v); } printf("\n"); if(dbg)printf(".\tcurly: h=%d b=%d n=%d v=%d l=%c, r=%c\n", eht[yyval], ebase[yyval], n, v, leftc, rightc); } brack(m, t, c, b) int m; char *t, *c, *b; { int j; printf("\\b'%s", t); for( j=0; j