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 /*	from OpenSolaris "eqnbox.c	1.3	05/06/02 SMI"	 SVr4.0 1.1		*/
17 
18 /*
19  * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
20  *
21  * Sccsid @(#)eqnbox.c	1.7 (gritter) 1/13/08
22  */
23 
24 /*
25  * Changes Copyright (c) 2014 Carsten Kunze (carsten.kunze at arcor.de)
26  */
27 
28 # include "e.h"
29 #include "y.tab.h"
30 
31 extern YYSTYPE yyval;
32 
33 void
eqnbox(int p1,int p2,int lu)34 eqnbox(int p1, int p2, int lu) {
35 #ifndef	NEQN
36 	float b, h;
37 #else	/* NEQN */
38 	int b, h;
39 #endif	/* NEQN */
40 	char *sh;
41 
42 	yyval.token = p1;
43 	b = max(ebase[p1], ebase[p2]);
44 	eht[yyval.token] = h = b + max(eht[p1]-ebase[p1],
45 		eht[p2]-ebase[p2]);
46 	ebase[yyval.token] = b;
47 #ifndef	NEQN
48 	if(dbg)printf(".\te:eb: S%d <- S%d S%d; b=%g, h=%g\n",
49 		yyval.token, p1, p2, b, h);
50 #else	/* NEQN */
51 	if(dbg)printf(".\te:eb: S%d <- S%d S%d; b=%d, h=%d\n",
52 		yyval.token, p1, p2, b, h);
53 #endif	/* NEQN */
54 	if (ital(rfont[p1]) && rom(lfont[p2])) {
55 		if (op(lfont[p2]))
56 			sh = "\\|";
57 		else
58 			sh = "\\^";
59 	} else
60 		sh = "";
61 	if (lu) {
62 		printf(".nr %d \\w'\\s%s\\*(%d%s'\n", p1, tsize(ps), p1, sh);
63 		printf(".ds %d \\h'|\\n(97u-\\n(%du'\\*(%d\n", p1, p1, p1);
64 	}
65 	printf(".as %d \"%s\\*(%d\n", yyval.token, sh, p2);
66 	rfont[p1] = rfont[p2];
67 	ofree(p2);
68 }
69