xref: /onnv-gate/usr/src/cmd/eqn/over.c (revision 364:f36290b8cb0b)
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 
17*364Sceastha #include "e.h"
180Sstevel@tonic-gate 
19*364Sceastha void
boverb(int p1,int p2)20*364Sceastha boverb(int p1, int p2)
21*364Sceastha {
220Sstevel@tonic-gate 	int h, b, treg, d;
230Sstevel@tonic-gate 
240Sstevel@tonic-gate 	treg = oalloc();
250Sstevel@tonic-gate 	yyval = p1;
260Sstevel@tonic-gate #ifndef NEQN
270Sstevel@tonic-gate 	d = VERT(EM(0.3, ps));
280Sstevel@tonic-gate 	h = eht[p1] + eht[p2] + d;
29*364Sceastha #else	/* NEQN */
300Sstevel@tonic-gate 	d = VERT(1);
310Sstevel@tonic-gate 	h = eht[p1] + eht[p2];
32*364Sceastha #endif	/* NEQN */
330Sstevel@tonic-gate 	b = eht[p2] - d;
34*364Sceastha 	if (dbg)
35*364Sceastha 		printf(".\tb:bob: S%d <- S%d over S%d; b=%d, h=%d\n",
36*364Sceastha 		    yyval, p1, p2, b, h);
370Sstevel@tonic-gate 	nrwid(p1, ps, p1);
380Sstevel@tonic-gate 	nrwid(p2, ps, p2);
390Sstevel@tonic-gate 	printf(".nr %d \\n(%d\n", treg, p1);
400Sstevel@tonic-gate 	printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2);
410Sstevel@tonic-gate #ifndef NEQN
420Sstevel@tonic-gate 	printf(".nr %d \\n(%d+\\s%d.5m\\s0\n", treg, treg, EFFPS(ps));
43*364Sceastha #endif	/* NEQN */
44*364Sceastha 	printf(".ds %d \\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n",
45*364Sceastha 	    yyval, eht[p2]-ebase[p2]-d, treg, p2, p2);
46*364Sceastha #ifndef	NEQN
47*364Sceastha 	printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n",
48*364Sceastha 	    p2, p1, -(eht[p2]-ebase[p2]+d+ebase[p1]), p1);
49*364Sceastha 	printf("\\h'-\\n(%du-\\n(%du/2u+.1m'\\v'%du'\\l'\\n"
50*364Sceastha 	    "(%du-.2m'\\h'.1m'\\v'%du'\n", treg, p1, ebase[p1]+d, treg, d);
51*364Sceastha #else	/* NEQN */
52*364Sceastha 	printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n",
53*364Sceastha 	    p2, p1, -eht[p2]+ebase[p2]-ebase[p1], p1);
54*364Sceastha 	printf("\\h'-\\n(%du-\\n(%du-2u/2u'\\v'%du'\\l'\\n(%du'\\v'%du'\n",
55*364Sceastha 	    treg, p1, ebase[p1], treg, d);
56*364Sceastha #endif	/* NEQN */
570Sstevel@tonic-gate 	ebase[yyval] = b;
580Sstevel@tonic-gate 	eht[yyval] = h;
590Sstevel@tonic-gate 	lfont[yyval] = rfont[yyval] = 0;
600Sstevel@tonic-gate 	ofree(p2);
610Sstevel@tonic-gate 	ofree(treg);
620Sstevel@tonic-gate }
63