xref: /illumos-gate/usr/src/cmd/eqn/size.c (revision e7cbe64f7a72dae5cb44f100db60ca88f3313c65)
1 /*
2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
10  * Copyright (c) 1980 Regents of the University of California.
11  * All rights reserved. The Berkeley software License Agreement
12  * specifies the terms and conditions for redistribution.
13  */
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17 #include "e.h"
18 
19 void
20 setsize(char *p)	/* set size as found in p */
21 {
22 	if (*p == '+')
23 		ps += atoi(p+1);
24 	else if (*p == '-')
25 		ps -= atoi(p+1);
26 	else
27 		ps = atoi(p);
28 	if (dbg) printf(".\tsetsize %s; ps = %d\n", p, ps);
29 }
30 
31 void
32 size(int p1, int p2)
33 {
34 	/* old size in p1, new in ps */
35 
36 	int effps, effp1;
37 
38 	yyval = p2;
39 	if (dbg)
40 		printf(".\tb:sb: S%d <- \\s%d S%d \\s%d; b=%d, h=%d\n",
41 		    yyval, ps, p2, p1, ebase[yyval], eht[yyval]);
42 	effps = EFFPS(ps);
43 	effp1 = EFFPS(p1);
44 	printf(".ds %d \\s%d\\*(%d\\s%d\n", yyval, effps, p2, effp1);
45 	ps = p1;
46 }
47 
48 void
49 globsize(void)
50 {
51 	char temp[20];
52 
53 	getstr(temp, 20);
54 	if (temp[0] == '+')
55 		gsize += atoi(temp+1);
56 	else if (temp[0] == '-')
57 		gsize -= atoi(temp+1);
58 	else
59 		gsize = atoi(temp);
60 	yyval = eqnreg = 0;
61 	setps(gsize);
62 	ps = gsize;
63 	if (gsize >= 12)	/* sub and sup size change */
64 		deltaps = gsize / 4;
65 	else
66 		deltaps = gsize / 3;
67 }
68