ifline() { while(1) { inline(); if(eof) return; if(match("#ifdef")) { ++iflevel; if(skiplevel) continue; blanks(); #ifdef HASH if(search(lptr, macn, NAMESIZE+2, MACNEND, MACNBR, 0)==0) #else /* HASH */ if(findmac(lptr)==0) #endif /* HASH */ skiplevel=iflevel; continue; } if(match("#ifndef")) { ++iflevel; if(skiplevel) continue; blanks(); #ifdef HASH if(search(lptr, macn, NAMESIZE+2, MACNEND, MACNBR, 0)) #else /* HASH */ if(findmac(lptr)) #endif /* HASH */ skiplevel=iflevel; continue; } if(match("#else")) { if(iflevel) { if(skiplevel==iflevel) skiplevel=0; else if(skiplevel==0) skiplevel=iflevel; } else noiferr(); continue; } if(match("#endif")) { if(iflevel) { if(skiplevel==iflevel) skiplevel=0; --iflevel; } else noiferr(); continue; } if(skiplevel) continue; if(listfp) { if(listfp==output) cout(';', output); lout(line, listfp); } if(ch==0) continue; break; } } keepch(c) char c; { if(pptr=LINEMAX) error("line too long"); keepch(0); line=pline; bump(0); } noiferr() { error("no matching #if..."); errflag=0; } addmac() { int k; if(symname(msname, NO)==0) { illname(); kill(); return; } k=0; #ifdef HASH if(search(msname, macn, NAMESIZE+2, MACNEND, MACNBR, 0)==0) { if(cptr2=cptr) while(*cptr2++ = msname[k++]); else { error("macro name table full"); return; } } putint(macptr, cptr+NAMESIZE, 2); #else /* HASH */ while(putmac(msname[k++])); #endif /* HASH */ while(white()) gch(); while(putmac(gch())); if(macptr>=MACMAX) { error("macro string queue full"); abort(ERRCODE); } } putmac(c) char c; { macq[macptr]=c; if(macptr= end) cptr=buf; if(cptr == cptr2) return (cptr=0); } return 0; } hash(sname) char *sname; { int i, c; i=0; while(c = *sname++) i=(i<<1)+c; return i; } #else /* HASH */ findmac(sname) char *sname; { mack=0; while(mack=1) { c=number/k + '0'; if ((c!='0')|(k==1)|(zs)) { zs=1; outbyte(c); } number=number%k; k=k/10; } } ol(ptr) char ptr[]; { ot(ptr); nl(); } ot(ptr) char ptr[]; { #ifdef TAB tab(); #else /* TAB */ outbyte(' '); #endif /* TAB */ outstr(ptr); } outstr(ptr) char ptr[]; { #ifdef POLL CCPOLL(1); /* allow program interruption */ #endif /* POLL */ /* must work with symbol table names terminated by length */ while(*ptr >= ' ') outbyte(*ptr++); } outbyte(c) char c; { if(stagenext) { if(stagenext==stagelast) { error("staging buffer overflow"); return 0; } else *stagenext++ = c; } else cout(c,output); return c; } cout(c, fd) char c; int fd; { #ifdef C80 if(putc(c, fd)==EOF) xout(); #else /* C80 */ if(fputc(c, fd)==EOF) xout(); #endif /* C80 */ } sout(string, fd) char *string; int fd; { if(fputs(string, fd)==EOF) xout(); } lout(line, fd) char *line; int fd; { sout(line, fd); cout('\n', fd); } xout() { fputs("output error\n", stderr); abort(ERRCODE); } #ifdef C80 abort(err) int err; { exit(); /* exit to CP/M */ } #endif /* C80 */ #ifdef C80 fputs(string, fd) char *string; int fd; { char c; while ((c = *string++) != NULL) { if (putc(c, fd) == EOF) return EOF; } return 0; } #endif /* C80 */ nl() { outbyte('\n'); } tab() { outbyte(TAB); } col() { #ifdef COL outbyte(':'); #else /* COL */ outbyte(' '); #endif /* COL */ } error(msg) char msg[]; { if(errflag) return; else errflag=1; lout(line, stderr); errout(msg, stderr); #ifdef C80 if(alarm) putc(7, stderr); #else /* C80 */ if(alarm) fputc(7, stderr); #endif /* C80 */ /* ** while reading from stderr is not strictly legal, ** stderr will always be assigned to the user's terminal ** (CON: on CP/M systems [should be /dev/tty on Unix]). */ if(pause) while(getc(stderr)!='\n'); if(listfp>0) errout(msg, listfp); } errout(msg, fp) char msg[]; int fp; { int k; k=line+2; while(k++ <= lptr) cout(' ', fp); lout("/\\", fp); sout("**** ", fp); lout(msg, fp); } streq(str1,str2) char str1[],str2[]; { /* check for string equality over whole string */ int k; k=0; while (str2[k]) { if ((str1[k])!=(str2[k])) return 0; ++k; } return k; } astreq(str1,str2,len) char str1[],str2[];int len; { /* check for string equality over first 'len' characters */ int k; k=0; while (k ' ') op[opsize++] = *list++; op[opsize]=0; if(opsize=streq(lptr, op)) if((*(lptr+opsize) != '=')& (*(lptr+opsize) != *(lptr+opsize-1))) return 1; if(*list) { ++list; ++opindex; } else return 0; } } blanks() { while(1) { while(ch) { if(white()) gch(); else return; } if(line==mline) return; preprocess(); if(eof)break; } }