xref: /onnv-gate/usr/src/cmd/eqn/fromto.c (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
2*0Sstevel@tonic-gate /*	  All Rights Reserved  	*/
3*0Sstevel@tonic-gate 
4*0Sstevel@tonic-gate 
5*0Sstevel@tonic-gate /*
6*0Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
7*0Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
8*0Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
9*0Sstevel@tonic-gate  */
10*0Sstevel@tonic-gate 
11*0Sstevel@tonic-gate /*
12*0Sstevel@tonic-gate  * Copyright (c) 1983, 1984 1985, 1986, 1987, 1988, Sun Microsystems, Inc.
13*0Sstevel@tonic-gate  * All Rights Reserved.
14*0Sstevel@tonic-gate  */
15*0Sstevel@tonic-gate 
16*0Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.1	*/
17*0Sstevel@tonic-gate 
18*0Sstevel@tonic-gate # include "e.h"
19*0Sstevel@tonic-gate 
20*0Sstevel@tonic-gate fromto(p1, p2, p3) int p1, p2, p3; {
21*0Sstevel@tonic-gate 	int b, h1, b1, pss;
22*0Sstevel@tonic-gate 	yyval = oalloc();
23*0Sstevel@tonic-gate 	lfont[yyval] = rfont[yyval] = 0;
24*0Sstevel@tonic-gate 	h1 = eht[yyval] = eht[p1];
25*0Sstevel@tonic-gate 	b1 = ebase[p1];
26*0Sstevel@tonic-gate 	b = 0;
27*0Sstevel@tonic-gate 	pss = EFFPS(ps);
28*0Sstevel@tonic-gate 	ps += 3;
29*0Sstevel@tonic-gate 	nrwid(p1, ps, p1);
30*0Sstevel@tonic-gate 	printf(".nr %d \\n(%d\n", yyval, p1);
31*0Sstevel@tonic-gate 	if( p2>0 ) {
32*0Sstevel@tonic-gate 		nrwid(p2, pss, p2);
33*0Sstevel@tonic-gate 		printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, yyval, yyval, p2);
34*0Sstevel@tonic-gate 		eht[yyval] += eht[p2];
35*0Sstevel@tonic-gate 		b = eht[p2];
36*0Sstevel@tonic-gate 	}
37*0Sstevel@tonic-gate 	if( p3>0 ) {
38*0Sstevel@tonic-gate 		nrwid(p3, pss, p3);
39*0Sstevel@tonic-gate 		printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p3, yyval, yyval, p3);
40*0Sstevel@tonic-gate 		eht[yyval] += eht[p3];
41*0Sstevel@tonic-gate 	}
42*0Sstevel@tonic-gate 	printf(".ds %d ", yyval);	/* bottom of middle box */
43*0Sstevel@tonic-gate 	if( p2>0 ) {
44*0Sstevel@tonic-gate 		printf("\\v'%du'\\h'\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d",
45*0Sstevel@tonic-gate 			eht[p2]-ebase[p2]+b1, yyval, p2, pss, p2, EFFPS(ps));
46*0Sstevel@tonic-gate 		printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%du'\\\n",
47*0Sstevel@tonic-gate 			yyval, p2, -(eht[p2]-ebase[p2]+b1));
48*0Sstevel@tonic-gate 	}
49*0Sstevel@tonic-gate #ifndef NEQN
50*0Sstevel@tonic-gate 	printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n",
51*0Sstevel@tonic-gate #else NEQN
52*0Sstevel@tonic-gate 	printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du+2u/2u'\\\n",
53*0Sstevel@tonic-gate #endif NEQN
54*0Sstevel@tonic-gate 		yyval, p1, p1, yyval, p1);
55*0Sstevel@tonic-gate 	if( p3>0 ) {
56*0Sstevel@tonic-gate 		printf("\\v'%du'\\h'-\\n(%du-\\n(%du/2u'\\s%d\\*(%d\\s%d\\h'\\n(%du-\\n(%du/2u'\\v'%du'\\\n",
57*0Sstevel@tonic-gate 			-(h1-b1+ebase[p3]), yyval, p3, pss, p3, EFFPS(ps), yyval, p3, (h1-b1+ebase[p3]));
58*0Sstevel@tonic-gate 	}
59*0Sstevel@tonic-gate 	printf("\n");
60*0Sstevel@tonic-gate 	ebase[yyval] = b + b1;
61*0Sstevel@tonic-gate 	if(dbg)printf(".\tfrom to: S%d <- %d f %d t %d; h=%d b=%d\n",
62*0Sstevel@tonic-gate 		yyval, p1, p2, p3, eht[yyval], ebase[yyval]);
63*0Sstevel@tonic-gate 	ofree(p1);
64*0Sstevel@tonic-gate 	if( p2>0 ) ofree(p2);
65*0Sstevel@tonic-gate 	if( p3>0 ) ofree(p3);
66*0Sstevel@tonic-gate }
67