xref: /csrg-svn/old/eqn/common_source/fromto.c (revision 11003)
1*11003Sshannon /*	fromto.c	4.1	83/02/11	*/
2*11003Sshannon 
3*11003Sshannon # include "e.h"
4*11003Sshannon 
5*11003Sshannon fromto(p1, p2, p3) int p1, p2, p3; {
6*11003Sshannon 	int b, h1, b1, pss;
7*11003Sshannon 	yyval = oalloc();
8*11003Sshannon 	lfont[yyval] = rfont[yyval] = 0;
9*11003Sshannon 	h1 = eht[yyval] = eht[p1];
10*11003Sshannon 	b1 = ebase[p1];
11*11003Sshannon 	b = 0;
12*11003Sshannon 	pss = EFFPS(ps);
13*11003Sshannon 	ps += 3;
14*11003Sshannon 	nrwid(p1, ps, p1);
15*11003Sshannon 	printf(".nr %d \\n(%d\n", yyval, p1);
16*11003Sshannon 	if( p2>0 ) {
17*11003Sshannon 		nrwid(p2, pss, p2);
18*11003Sshannon 		printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, yyval, yyval, p2);
19*11003Sshannon 		eht[yyval] += eht[p2];
20*11003Sshannon 		b = eht[p2];
21*11003Sshannon 	}
22*11003Sshannon 	if( p3>0 ) {
23*11003Sshannon 		nrwid(p3, pss, p3);
24*11003Sshannon 		printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p3, yyval, yyval, p3);
25*11003Sshannon 		eht[yyval] += eht[p3];
26*11003Sshannon 	}
27*11003Sshannon 	printf(".ds %d ", yyval);	/* bottom of middle box */
28*11003Sshannon 	if( p2>0 ) {
29*11003Sshannon 		printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d",
30*11003Sshannon 			eht[p2]-ebase[p2]+b1, yyval, p2, pss, p2, EFFPS(ps));
31*11003Sshannon 		printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\\n",
32*11003Sshannon 			yyval, p2, -(eht[p2]-ebase[p2]+b1));
33*11003Sshannon 	}
34*11003Sshannon 	printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n",
35*11003Sshannon 		yyval, p1, p1, yyval, p1);
36*11003Sshannon 	if( p3>0 ) {
37*11003Sshannon 		printf("\\v'%du'\\h'-\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d\\h'\\n(%du-\\n(%du/2u'\\v'%du'\\\n",
38*11003Sshannon 			-(h1-b1+ebase[p3]), yyval, p3, pss, p3, EFFPS(ps), yyval, p3, (h1-b1+ebase[p3]));
39*11003Sshannon 	}
40*11003Sshannon 	printf("\n");
41*11003Sshannon 	ebase[yyval] = b + b1;
42*11003Sshannon 	if(dbg)printf(".\tfrom to: S%d <- %d f %d t %d; h=%d b=%d\n",
43*11003Sshannon 		yyval, p1, p2, p3, eht[yyval], ebase[yyval]);
44*11003Sshannon 	ofree(p1);
45*11003Sshannon 	if( p2>0 ) ofree(p2);
46*11003Sshannon 	if( p3>0 ) ofree(p3);
47*11003Sshannon }
48