/* ** open an include file */ doinclude() { char c, *fname, buff[15]; int i; /* * test for nested includes added 4/7/83 br. * (this may be buried somewhere else, but I don't see it) */ if(input2 != EOF) { error("nested include files not allowed"); kill(); /* ignore rest of line */ return; } blanks(); /* skip over to name */ /* * added code to handle include filename in quotes or brackets * 4/5/83 br */ if ((*lptr == '"') | (*lptr == '<')) { i = 0; fname = buff; while (i<14) { c = *++lptr; if ((c == '"') | (c == '>')) i = 14; /* force exit from loop */ else *fname++ = c; } *fname = '\0'; fname = buff; } else fname = lptr; /* no '"' or '<' (original convention) */ if((input2=fopen(fname,"r"))==NULL) { input2= EOF; error("open failure on include file"); } kill(); /* clear rest of line */ /* so next read will come from */ /* new file (if open) */ } /* ** test for global declarations */ dodeclare(class) int class; { if(amatch("char",4)) { declglb(CCHAR, class); ns(); return 1; } else if((amatch("int",3))|(class==EXTERNAL)) { declglb(CINT, class); ns(); return 1; } return 0; } /* ** declare a static variable */ declglb(type, class) int type, class; { int k, j; while(1) { if(endst()) return; /* do line */ if(match("*")) { j=POINTER; k=0; } else { j=VARIABLE; k=1; } if (symname(ssname, YES)==0) illname(); if(findglb(ssname)) multidef(ssname); if(match("()")) j=FUNCTION; else if (match("[")) { k=needsub(); /* get size */ /* * check for `*var[nn]' 4/7/83 br */ if (j==POINTER) error("declaration type not allowed"); j=ARRAY; /* !0=array */ /* I don't understand this comment. br */ } if(class==EXTERNAL) external(ssname); else j=initials(type>>2, j, k); addsym(ssname, j, type, k, &glbptr, class); if (match(",")==0) return; /* more? */ } } /* ** declare local variables */ declloc(typ) int typ; { int k,j; #ifdef STGOTO if(noloc) error("not allowed with goto"); #endif /* STGOTO */ if(declared < 0) error("must declare first in block"); while(1) { while(1) { if(endst()) return; if(match("*")) j=POINTER; else j=VARIABLE; if (symname(ssname, YES)==0) illname(); /* no multidef check, block-locals are together */ k=BPW; if (match("[")) { k=needsub(); if(k) { /* * check for `*var[nn]' 4/7/83 br */ if (j==POINTER) error("declaration type not allowed"); j=ARRAY; if(typ==CINT)k=k<