4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
34 #define BLK sizeof (struct blk)
35 #define PTRSZ sizeof (int *)
44 #define length(p) ((p)->wt-(p)->beg)
45 #define rewind(p) ((p)->rd = (p)->beg)
46 #define create(p) ((p)->rd = (p)->wt = (p)->beg)
47 #define fsfile(p) ((p)->rd = (p)->wt)
48 #define truncate(p) ((p)->wt = (p)->rd)
49 #define sfeof(p) (((p)->rd >= (p)->wt) ? 1 : 0)
50 #define sfbeg(p) (((p)->rd == (p)->beg) ? 1 : 0)
51 #define sungetc(p, c) (*(--(p)->rd) = c)
52 #define sgetc(p) (((p)->rd == (p)->wt) ? EOF: ctoint((int)*(p)->rd++))
53 #define slookc(p) (((p)->rd == (p)->wt) ? EOF: ctoint((int)*(p)->rd))
54 #define sbackc(p) (((p)->rd == (p)->beg) ? EOF: ctoint((int)*(--(p)->rd)))
55 #define sputc(p, c) {if ((p)->wt == (p)->last) more(p); *(p)->wt++ = c; }
56 #define salterc(p, c) {if ((p)->rd == (p)->last) more(p); *(p)->rd++ = c;\
57 if ((p)->rd > (p)->wt) (p)->wt = (p)->rd; }
58 #define sunputc(p) (*((p)->rd = --(p)->wt))
59 #define zero(p) for (pp = (p)->beg; pp < (p)->last; ) *pp++ = '\0'
60 #define OUTC(x) {printf("%c", x); if (--count == 0)\
61 {printf("\\\n"); count = ll; } }
62 #define TEST2 {if ((count -= 2) <= 0) {printf("\\\n"); count = ll; } }
63 #define PRINT_MESSAGE printf(gettext("stack empty\n"))
64 #define EMPTY if (stkerr != 0) {PRINT_MESSAGE; continue; }
65 #define EMPTYR(x) if (stkerr != 0) {pushp(x); PRINT_MESSAGE; continue; }
66 #define EMPTYS if (stkerr != 0) {PRINT_MESSAGE; return (1); }
67 #define EMPTYSR(x) if (stkerr != 0) {PRINT_MESSAGE; pushp(x); return (1); }
74 #define error(p) {printf(p); continue; }
75 #define errorrt(p) {printf(p); return (1); }
89 struct blk
*getwd(struct blk
*);
90 struct blk
*lookwd(struct blk
*);
91 struct blk
*getdec(struct blk
*, int);
92 struct blk
*morehd(void);
94 struct blk
*arg1
, *arg2
;
101 struct blk
*scalptr
, *basptr
, *tenptr
, *inbas
;
102 struct blk
*sqtemp
, *chptr
, *strptr
, *divxyz
;
103 struct blk
*stack
[STKSZ
];
104 struct blk
**stkptr
, **stkbeg
;
108 struct blk
*readstk
[RDSKSZ
];
109 struct blk
**readptr
;
114 struct blk
*pop(void), *readin(void), *add0(struct blk
*, int),
115 *mult(struct blk
*, struct blk
*);
116 struct blk
*scalint(struct blk
*);
117 struct blk
*removc(struct blk
*, int);
118 struct blk
*add(struct blk
*, struct blk
*),
119 *dcdiv(struct blk
*, struct blk
*), *removr(struct blk
*, int);
120 struct blk
*exp(struct blk
*, struct blk
*);
121 struct blk
*sqrt(struct blk
*);
122 struct blk
*salloc(int), *copy(struct blk
*, int);
123 struct blk
*scale(struct blk
*, int);
125 void init(int, char **);
126 void pushp(struct blk
*p
);
127 void chsign(struct blk
*p
);
131 void print(struct blk
*hptr
);
132 void tenot(struct blk
*p
, int sc
);
133 void oneot(struct blk
*p
, int sc
, char ch
);
134 void seekc(struct blk
*hptr
, int n
);
135 void ospace(char *s
);
136 void garbage(char *s
);
137 void more(struct blk
*hptr
);
140 void sdump(char *s1
, struct blk
*hptr
);
141 void salterwd(struct wblk
*hptr
, struct blk
*n
);
142 void redef(struct blk
*p
);
143 void release(struct blk
*p
);
144 void putwd(struct blk
*p
, struct blk
*c
);
151 struct sym
*stable
[TBLSZ
];
152 struct sym
*sptr
, *sfree
;
160 void (*outdit
)(struct blk
*, int);
161 void bigot(struct blk
*, int), hexot(struct blk
*, int);
167 char *nalloc(char *, unsigned int);