1 /*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 * 7 * @(#)dc.h 8.1 (Berkeley) 06/06/93 8 */ 9 10 #define FATAL 0 11 #define NFATAL 1 12 #define BLK sizeof(struct blk) 13 #define PTRSZ sizeof(int *) 14 #define HEADSZ 1024 15 #define STKSZ 100 16 #define RDSKSZ 100 17 #define TBLSZ 256 18 #define ARRAYST 0241 19 #define MAXIND 2048 20 #define NL 1 21 #define NG 2 22 #define NE 3 23 #define length(p) ((p)->wt-(p)->beg) 24 #define rewind(p) (p)->rd=(p)->beg 25 #define create(p) (p)->rd = (p)->wt = (p)->beg 26 #define fsfile(p) (p)->rd = (p)->wt 27 #define truncate(p) (p)->wt = (p)->rd 28 #define sfeof(p) (((p)->rd==(p)->wt)?1:0) 29 #define sfbeg(p) (((p)->rd==(p)->beg)?1:0) 30 #define sungetc(p,c) *(--(p)->rd)=c 31 #ifdef interdata 32 #define NEGBYTE 0200 33 #define MASK (-1 & ~0377) 34 #define sgetc(p) ( ((p)->rd==(p)->wt) ? EOF :( ((*(p)->rd & NEGBYTE) != 0) ? ( *(p)->rd++ | MASK): *(p)->rd++ )) 35 #define slookc(p) ( ((p)->rd==(p)->wt) ? EOF :( ((*(p)->rd & NEGBYTE) != 0) ? (*(p)->rd | MASK) : *(p)->rd )) 36 #define sbackc(p) ( ((p)->rd==(p)->beg) ? EOF :( ((*(--(p)->rd) & NEGBYTE) != 0) ? (*(p)->rd | MASK): *(p)->rd )) 37 #endif 38 #ifndef interdata 39 #define sgetc(p) (((p)->rd==(p)->wt)?EOF:*(p)->rd++) 40 #define slookc(p) (((p)->rd==(p)->wt)?EOF:*(p)->rd) 41 #define sbackc(p) (((p)->rd==(p)->beg)?EOF:*(--(p)->rd)) 42 #endif 43 #define sputc(p,c) {if((p)->wt==(p)->last)more(p); *(p)->wt++ = c; } 44 #define salterc(p,c) {if((p)->rd==(p)->last)more(p); *(p)->rd++ = c; if((p)->rd>(p)->wt)(p)->wt=(p)->rd;} 45 #define sunputc(p) (*( (p)->rd = --(p)->wt)) 46 #define zero(p) for(pp=(p)->beg;pp<(p)->last;)*pp++='\0' 47 #define OUTC(x) {printf("%c",x); if(--count == 0){printf("\\\n"); count=ll;} } 48 #define TEST2 {if((count -= 2) <=0){printf("\\\n");count=ll;}} 49 #define EMPTY if(stkerr != 0){printf("stack empty\n"); continue; } 50 #define EMPTYR(x) if(stkerr!=0){pushp(x);printf("stack empty\n");continue;} 51 #define EMPTYS if(stkerr != 0){printf("stack empty\n"); return(1);} 52 #define EMPTYSR(x) if(stkerr !=0){printf("stack empty\n");pushp(x);return(1);} 53 #define error(p) {printf(p); continue; } 54 #define errorrt(p) {printf(p); return(1); } 55 struct blk { 56 char *rd; 57 char *wt; 58 char *beg; 59 char *last; 60 }; 61 struct blk *hfree; 62 struct blk *getwd(); 63 struct blk *lookwd(); 64 struct blk *getdec(); 65 struct blk *morehd(); 66 67 struct blk *arg1, *arg2; 68 int svargc; 69 char savk; 70 char **svargv; 71 int dbg; 72 int ifile; 73 FILE *curfile; 74 struct blk *scalptr, *basptr, *tenptr, *inbas; 75 struct blk *sqtemp, *chptr, *strptr, *divxyz; 76 struct blk *stack[STKSZ]; 77 struct blk **stkptr,**stkbeg; 78 struct blk **stkend; 79 int stkerr; 80 int lastchar; 81 struct blk *readstk[RDSKSZ]; 82 struct blk **readptr; 83 struct blk *rem; 84 int k; 85 struct blk *irem; 86 int skd,skr; 87 struct blk *pop(),*readin(),*add0(),*mult(); 88 struct blk *scalint(); 89 struct blk *removc(); 90 struct blk *add(),*div(),*removr(); 91 struct blk *exp(); 92 struct blk *dcsqrt(); 93 struct blk *salloc(),*copy(); 94 struct blk *scale(); 95 int neg; 96 struct sym { 97 struct sym *next; 98 struct blk *val; 99 } symlst[TBLSZ]; 100 struct sym *stable[TBLSZ]; 101 struct sym *sptr,*sfree; 102 struct wblk { 103 struct blk **rdw; 104 struct blk **wtw; 105 struct blk **begw; 106 struct blk **lastw; 107 }; 108 FILE *fsave; 109 long rel; 110 long nbytes; 111 long all; 112 long headmor; 113 long obase; 114 int fw,fw1,ll; 115 int (*outdit)(); 116 int bigot(),hexot(); 117 int logo; 118 int log10; 119 int count; 120 char *pp; 121 void onintr(); 122 char *malloc(); 123 char *nalloc(); 124 char *realloc(); 125