xref: /illumos-gate/usr/src/cmd/eqn/over.c (revision 2a8bcb4e)
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
boverb(int p1,int p2)18 boverb(int p1, int p2)
19 {
20 	int h, b, treg, d;
21 
22 	treg = oalloc();
23 	yyval = p1;
24 #ifndef NEQN
25 	d = VERT(EM(0.3, ps));
26 	h = eht[p1] + eht[p2] + d;
27 #else	/* NEQN */
28 	d = VERT(1);
29 	h = eht[p1] + eht[p2];
30 #endif	/* NEQN */
31 	b = eht[p2] - d;
32 	if (dbg)
33 		printf(".\tb:bob: S%d <- S%d over S%d; b=%d, h=%d\n",
34 		    yyval, p1, p2, b, h);
35 	nrwid(p1, ps, p1);
36 	nrwid(p2, ps, p2);
37 	printf(".nr %d \\n(%d\n", treg, p1);
38 	printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, treg, treg, p2);
39 #ifndef NEQN
40 	printf(".nr %d \\n(%d+\\s%d.5m\\s0\n", treg, treg, EFFPS(ps));
41 #endif	/* NEQN */
42 	printf(".ds %d \\v'%du'\\h'\\n(%du-\\n(%du/2u'\\*(%d\\\n",
43 	    yyval, eht[p2]-ebase[p2]-d, treg, p2, p2);
44 #ifndef	NEQN
45 	printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n",
46 	    p2, p1, -(eht[p2]-ebase[p2]+d+ebase[p1]), p1);
47 	printf("\\h'-\\n(%du-\\n(%du/2u+.1m'\\v'%du'\\l'\\n"
48 	    "(%du-.2m'\\h'.1m'\\v'%du'\n", treg, p1, ebase[p1]+d, treg, d);
49 #else	/* NEQN */
50 	printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\*(%d\\\n",
51 	    p2, p1, -eht[p2]+ebase[p2]-ebase[p1], p1);
52 	printf("\\h'-\\n(%du-\\n(%du-2u/2u'\\v'%du'\\l'\\n(%du'\\v'%du'\n",
53 	    treg, p1, ebase[p1], treg, d);
54 #endif	/* NEQN */
55 	ebase[yyval] = b;
56 	eht[yyval] = h;
57 	lfont[yyval] = rfont[yyval] = 0;
58 	ofree(p2);
59 	ofree(treg);
60 }
61