xref: /illumos-gate/usr/src/cmd/eqn/size.c (revision 1725e09f9fca72291210d9663e76ea00fb8290bd)
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 #include "e.h"
16 
17 void
18 setsize(char *p)	/* set size as found in p */
19 {
20 	if (*p == '+')
21 		ps += atoi(p+1);
22 	else if (*p == '-')
23 		ps -= atoi(p+1);
24 	else
25 		ps = atoi(p);
26 	if (dbg) printf(".\tsetsize %s; ps = %d\n", p, ps);
27 }
28 
29 void
30 size(int p1, int p2)
31 {
32 	/* old size in p1, new in ps */
33 
34 	int effps, effp1;
35 
36 	yyval = p2;
37 	if (dbg)
38 		printf(".\tb:sb: S%d <- \\s%d S%d \\s%d; b=%d, h=%d\n",
39 		    yyval, ps, p2, p1, ebase[yyval], eht[yyval]);
40 	effps = EFFPS(ps);
41 	effp1 = EFFPS(p1);
42 	printf(".ds %d \\s%d\\*(%d\\s%d\n", yyval, effps, p2, effp1);
43 	ps = p1;
44 }
45 
46 void
47 globsize(void)
48 {
49 	char temp[20];
50 
51 	getstr(temp, 20);
52 	if (temp[0] == '+')
53 		gsize += atoi(temp+1);
54 	else if (temp[0] == '-')
55 		gsize -= atoi(temp+1);
56 	else
57 		gsize = atoi(temp);
58 	yyval = eqnreg = 0;
59 	setps(gsize);
60 	ps = gsize;
61 	if (gsize >= 12)	/* sub and sup size change */
62 		deltaps = gsize / 4;
63 	else
64 		deltaps = gsize / 3;
65 }
66