xref: /csrg-svn/old/eqn/common_source/fromto.c (revision 14485)
1*14485Ssam #ifndef lint
2*14485Ssam static char sccsid[] = "@(#)fromto.c	4.3 08/11/83";
3*14485Ssam #endif
411003Sshannon 
511003Sshannon # include "e.h"
611003Sshannon 
711003Sshannon fromto(p1, p2, p3) int p1, p2, p3; {
811003Sshannon 	int b, h1, b1, pss;
911003Sshannon 	yyval = oalloc();
1011003Sshannon 	lfont[yyval] = rfont[yyval] = 0;
1111003Sshannon 	h1 = eht[yyval] = eht[p1];
1211003Sshannon 	b1 = ebase[p1];
1311003Sshannon 	b = 0;
1411003Sshannon 	pss = EFFPS(ps);
1511003Sshannon 	ps += 3;
1611003Sshannon 	nrwid(p1, ps, p1);
1711003Sshannon 	printf(".nr %d \\n(%d\n", yyval, p1);
1811003Sshannon 	if( p2>0 ) {
1911003Sshannon 		nrwid(p2, pss, p2);
2011003Sshannon 		printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, yyval, yyval, p2);
2111003Sshannon 		eht[yyval] += eht[p2];
2211003Sshannon 		b = eht[p2];
2311003Sshannon 	}
2411003Sshannon 	if( p3>0 ) {
2511003Sshannon 		nrwid(p3, pss, p3);
2611003Sshannon 		printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p3, yyval, yyval, p3);
2711003Sshannon 		eht[yyval] += eht[p3];
2811003Sshannon 	}
2911003Sshannon 	printf(".ds %d ", yyval);	/* bottom of middle box */
3011003Sshannon 	if( p2>0 ) {
3111003Sshannon 		printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d",
3211003Sshannon 			eht[p2]-ebase[p2]+b1, yyval, p2, pss, p2, EFFPS(ps));
3311003Sshannon 		printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\\n",
3411003Sshannon 			yyval, p2, -(eht[p2]-ebase[p2]+b1));
3511003Sshannon 	}
3611023Sshannon #ifndef NEQN
3711003Sshannon 	printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n",
3811023Sshannon #else NEQN
3911023Sshannon 	printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du+2u/2u'\\\n",
4011023Sshannon #endif NEQN
4111003Sshannon 		yyval, p1, p1, yyval, p1);
4211003Sshannon 	if( p3>0 ) {
4311003Sshannon 		printf("\\v'%du'\\h'-\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d\\h'\\n(%du-\\n(%du/2u'\\v'%du'\\\n",
4411003Sshannon 			-(h1-b1+ebase[p3]), yyval, p3, pss, p3, EFFPS(ps), yyval, p3, (h1-b1+ebase[p3]));
4511003Sshannon 	}
4611003Sshannon 	printf("\n");
4711003Sshannon 	ebase[yyval] = b + b1;
4811003Sshannon 	if(dbg)printf(".\tfrom to: S%d <- %d f %d t %d; h=%d b=%d\n",
4911003Sshannon 		yyval, p1, p2, p3, eht[yyval], ebase[yyval]);
5011003Sshannon 	ofree(p1);
5111003Sshannon 	if( p2>0 ) ofree(p2);
5211003Sshannon 	if( p3>0 ) ofree(p3);
5311003Sshannon }
54