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