1 #ifndef lint 2 static char sccsid[] = "@(#)cpp.c 1.13 11/07/85"; 3 #endif lint 4 5 #ifdef FLEXNAMES 6 #define NCPS 128 7 #else 8 #define NCPS 8 9 #endif 10 11 # include "stdio.h" 12 # include "ctype.h" 13 /* C command 14 /* written by John F. Reiser 15 /* July/August 1978 16 */ 17 18 #define STATIC 19 20 #define FIRSTOPEN -2 21 #define STDIN 0 22 #define READ 0 23 #define WRITE 1 24 #define SALT '#' 25 #if !defined BUFSIZ || BUFSIZ < 8192 26 #undef BUFSIZ 27 #define BUFSIZ 8192 28 #endif 29 30 char *pbeg,*pbuf,*pend; 31 char *outp,*inp; 32 char *newp; 33 char cinit; 34 35 /* some code depends on whether characters are sign or zero extended */ 36 /* #if '\377' < 0 not used here, old cpp doesn't understand */ 37 #if pdp11 | vax | mc68000 38 #define COFF 128 39 #else 40 #define COFF 0 41 #endif 42 43 # if gcos 44 #define ALFSIZ 512 /* alphabet size */ 45 # else 46 #define ALFSIZ 256 /* alphabet size */ 47 # endif 48 char macbit[ALFSIZ+11]; 49 char toktyp[ALFSIZ]; 50 #define BLANK 1 51 #define IDENT 2 52 #define NUMBR 3 53 54 /* a superimposed code is used to reduce the number of calls to the 55 /* symbol table lookup routine. (if the kth character of an identifier 56 /* is 'a' and there are no macro names whose kth character is 'a' 57 /* then the identifier cannot be a macro name, hence there is no need 58 /* to look in the symbol table.) 'scw1' enables the test based on 59 /* single characters and their position in the identifier. 'scw2' 60 /* enables the test based on adjacent pairs of characters and their 61 /* position in the identifier. scw1 typically costs 1 indexed fetch, 62 /* an AND, and a jump per character of identifier, until the identifier 63 /* is known as a non-macro name or until the end of the identifier. 64 /* scw1 is inexpensive. scw2 typically costs 4 indexed fetches, 65 /* an add, an AND, and a jump per character of identifier, but it is also 66 /* slightly more effective at reducing symbol table searches. 67 /* scw2 usually costs too much because the symbol table search is 68 /* usually short; but if symbol table search should become expensive, 69 /* the code is here. 70 /* using both scw1 and scw2 is of dubious value. 71 */ 72 #define scw1 1 73 #define scw2 0 74 75 #if scw2 76 char t21[ALFSIZ],t22[ALFSIZ],t23[ALFSIZ+NCPS]; 77 #endif 78 79 #if scw1 80 #define b0 1 81 #define b1 2 82 #define b2 4 83 #define b3 8 84 #define b4 16 85 #define b5 32 86 #define b6 64 87 #define b7 128 88 #endif 89 90 #define IB 1 91 #define SB 2 92 #define NB 4 93 #define CB 8 94 #define QB 16 95 #define WB 32 96 char fastab[ALFSIZ]; 97 char slotab[ALFSIZ]; 98 char *ptrtab; 99 #define isslo (ptrtab==(slotab+COFF)) 100 #define isid(a) ((fastab+COFF)[a]&IB) 101 #define isspc(a) (ptrtab[a]&SB) 102 #define isnum(a) ((fastab+COFF)[a]&NB) 103 #define iscom(a) ((fastab+COFF)[a]&CB) 104 #define isquo(a) ((fastab+COFF)[a]&QB) 105 #define iswarn(a) ((fastab+COFF)[a]&WB) 106 107 #define eob(a) ((a)>=pend) 108 #define bob(a) (pbeg>=(a)) 109 110 # define cputc(a,b) if(!flslvl) putc(a,b) 111 112 char buffer[NCPS+BUFSIZ+BUFSIZ+NCPS]; 113 114 char *lastcopy; 115 116 char *malloc(), *realloc(); 117 118 # define DROP 0xFE /* special character not legal ASCII or EBCDIC */ 119 # define WARN DROP 120 # define SAME 0 121 # define MAXINC 10 122 # define MAXFRE 14 /* max buffers of macro pushback */ 123 # define MAXFRM 31 /* max number of formals/actuals to a macro */ 124 125 static char warnc = WARN; 126 127 int mactop,fretop; 128 char *instack[MAXFRE],*bufstack[MAXFRE],*endbuf[MAXFRE]; 129 130 int plvl; /* parenthesis level during scan for macro actuals */ 131 int maclin; /* line number of macro call requiring actuals */ 132 char *macfil; /* file name of macro call requiring actuals */ 133 char *macnam; /* name of macro requiring actuals */ 134 int maclvl; /* # calls since last decrease in nesting level */ 135 char *macforw; /* pointer which must be exceeded to decrease nesting level */ 136 int macdam; /* offset to macforw due to buffer shifting */ 137 138 #if tgp 139 int tgpscan; /* flag for dump(); */ 140 #endif 141 142 STATIC int inctop[MAXINC]; 143 STATIC char *fnames[MAXINC]; 144 STATIC char *dirnams[MAXINC]; /* actual directory of #include files */ 145 STATIC int fins[MAXINC]; 146 STATIC int lineno[MAXINC]; 147 148 STATIC char *dirs[10]; /* -I and <> directories */ 149 char *strdex(), *copy(), *subst(), *trmdir(); 150 struct symtab *stsym(); 151 STATIC int fin = FIRSTOPEN; 152 STATIC FILE *fout = stdout; 153 STATIC int nd = 1; 154 STATIC int pflag; /* don't put out lines "# 12 foo.c" */ 155 int passcom; /* don't delete comments */ 156 int incomment; /* True if parsing a comment */ 157 STATIC int rflag; /* allow macro recursion */ 158 STATIC int mflag; /* generate makefile dependencies */ 159 STATIC char *infile; /* name of .o file to build dependencies from */ 160 STATIC FILE *mout; /* file to place dependencies on */ 161 #define START 1 162 #define CONT 2 163 #define BACK 3 164 STATIC int ifno; 165 # define NPREDEF 20 166 STATIC char *prespc[NPREDEF]; 167 STATIC char **predef = prespc; 168 STATIC char *punspc[NPREDEF]; 169 STATIC char **prund = punspc; 170 STATIC int exfail; 171 struct symtab { 172 char *name; 173 char *value; 174 } *lastsym, *lookup(), *slookup(); 175 176 # if gcos 177 #include <setjmp.h> 178 static jmp_buf env; 179 # define main mainpp 180 # undef exit 181 # define exit(S) longjmp(env, 1) 182 # define open(S,D) fileno(fopen(S, "r")) 183 # define close(F) fclose(_f[F]) 184 extern FILE *_f[]; 185 # define symsiz 500 186 # else 187 # define symsiz 2000 /* std = 500, wnj aug 1979 */ 188 # endif 189 STATIC struct symtab stab[symsiz]; 190 191 STATIC struct symtab *defloc; 192 STATIC struct symtab *udfloc; 193 STATIC struct symtab *incloc; 194 STATIC struct symtab *ifloc; 195 STATIC struct symtab *elsloc; 196 STATIC struct symtab *eifloc; 197 STATIC struct symtab *ifdloc; 198 STATIC struct symtab *ifnloc; 199 STATIC struct symtab *ysysloc; 200 STATIC struct symtab *varloc; 201 STATIC struct symtab *lneloc; 202 STATIC struct symtab *ulnloc; 203 STATIC struct symtab *uflloc; 204 STATIC struct symtab *identloc; /* Sys 5r3 compatibility */ 205 STATIC int trulvl; 206 STATIC int flslvl; 207 208 sayline(where) 209 int where; 210 { 211 if (mflag && where==START) fprintf(mout, "%s: %s\n", infile, fnames[ifno]); 212 if (pflag==0) fprintf(fout,"# %d \"%s\"\n", lineno[ifno], fnames[ifno]); 213 } 214 215 /* data structure guide 216 /* 217 /* most of the scanning takes place in the buffer: 218 /* 219 /* (low address) (high address) 220 /* pbeg pbuf pend 221 /* | <-- BUFSIZ chars --> | <-- BUFSIZ chars --> | 222 /* _______________________________________________________________________ 223 /* |_______________________________________________________________________| 224 /* | | | 225 /* |<-- waiting -->| |<-- waiting --> 226 /* | to be |<-- current -->| to be 227 /* | written | token | scanned 228 /* | | | 229 /* outp inp p 230 /* 231 /* *outp first char not yet written to output file 232 /* *inp first char of current token 233 /* *p first char not yet scanned 234 /* 235 /* macro expansion: write from *outp to *inp (chars waiting to be written), 236 /* ignore from *inp to *p (chars of the macro call), place generated 237 /* characters in front of *p (in reverse order), update pointers, 238 /* resume scanning. 239 /* 240 /* symbol table pointers point to just beyond the end of macro definitions; 241 /* the first preceding character is the number of formal parameters. 242 /* the appearance of a formal in the body of a definition is marked by 243 /* 2 chars: the char WARN, and a char containing the parameter number. 244 /* the first char of a definition is preceded by a zero character. 245 /* 246 /* when macro expansion attempts to back up over the beginning of the 247 /* buffer, some characters preceding *pend are saved in a side buffer, 248 /* the address of the side buffer is put on 'instack', and the rest 249 /* of the main buffer is moved to the right. the end of the saved buffer 250 /* is kept in 'endbuf' since there may be nulls in the saved buffer. 251 /* 252 /* similar action is taken when an 'include' statement is processed, 253 /* except that the main buffer must be completely emptied. the array 254 /* element 'inctop[ifno]' records the last side buffer saved when 255 /* file 'ifno' was included. these buffers remain dormant while 256 /* the file is being read, and are reactivated at end-of-file. 257 /* 258 /* instack[0 : mactop] holds the addresses of all pending side buffers. 259 /* instack[inctop[ifno]+1 : mactop-1] holds the addresses of the side 260 /* buffers which are "live"; the side buffers instack[0 : inctop[ifno]] 261 /* are dormant, waiting for end-of-file on the current file. 262 /* 263 /* space for side buffers is obtained from 'malloc' and is never returned. 264 /* bufstack[0:fretop-1] holds addresses of side buffers which 265 /* are available for use. 266 */ 267 268 dump() { 269 /* write part of buffer which lies between outp and inp . 270 /* this should be a direct call to 'write', but the system slows to a crawl 271 /* if it has to do an unaligned copy. thus we buffer. this silly loop 272 /* is 15% of the total time, thus even the 'putc' macro is too slow. 273 */ 274 register char *p1,*p2; register FILE *f; 275 if ((p1=outp)==inp || flslvl!=0) return; 276 #if tgp 277 #define MAXOUT 80 278 if (!tgpscan) {/* scan again to insure <= MAXOUT chars between linefeeds */ 279 register char c,*pblank; char savc,stopc,brk; 280 tgpscan=1; brk=stopc=pblank=0; p2=inp; savc= *p2; *p2='\0'; 281 while (c= *p1++) { 282 if (c=='\\') c= *p1++; 283 if (stopc==c) stopc=0; 284 else if (c=='"' || c=='\'') stopc=c; 285 if (p1-outp>MAXOUT && pblank!=0) { 286 *pblank++='\n'; inp=pblank; dump(); brk=1; pblank=0; 287 } 288 if (c==' ' && stopc==0) pblank=p1-1; 289 } 290 if (brk) sayline(CONT); 291 *p2=savc; inp=p2; p1=outp; tgpscan=0; 292 } 293 #endif 294 f=fout; 295 # if gcos 296 /* filter out "$ program c" card if first line of input */ 297 /* gmatch is a simple pattern matcher in the GCOS Standard Library */ 298 { static int gmfirst = 0; 299 if (!gmfirst) { 300 ++gmfirst; 301 if (gmatch(p1, "^$*program[ \t]*c*")) 302 p1 = strdex(p1, '\n'); 303 } 304 } 305 # endif 306 while (p1<inp) putc(*p1++,f); 307 outp=p1; 308 } 309 310 char * 311 refill(p) register char *p; { 312 /* dump buffer. save chars from inp to p. read into buffer at pbuf, 313 /* contiguous with p. update pointers, return new p. 314 */ 315 register char *np,*op; register int ninbuf; 316 dump(); np=pbuf-(p-inp); op=inp; 317 if (bob(np+1)) {pperror("token too long"); np=pbeg; p=inp+BUFSIZ;} 318 macdam += np-inp; outp=inp=np; 319 while (op<p) *np++= *op++; 320 p=np; 321 for (;;) { 322 if (mactop>inctop[ifno]) {/* retrieve hunk of pushed-back macro text */ 323 op=instack[--mactop]; np=pbuf; 324 do {while (*np++= *op++);} while (op<endbuf[mactop]); pend=np-1; 325 /* make buffer space avail for 'include' processing */ 326 if (fretop<MAXFRE) bufstack[fretop++]=instack[mactop]; 327 return(p); 328 } else {/* get more text from file(s) */ 329 maclvl=0; 330 if (0<(ninbuf=read(fin,pbuf,BUFSIZ))) { 331 pend=pbuf+ninbuf; *pend='\0'; 332 return(p); 333 } 334 /* end of #include file */ 335 if (ifno==0) {/* end of input */ 336 if (plvl!=0) { 337 int n=plvl,tlin=lineno[ifno]; char *tfil=fnames[ifno]; 338 lineno[ifno]=maclin; fnames[ifno]=macfil; 339 pperror("%s: unterminated macro call",macnam); 340 lineno[ifno]=tlin; fnames[ifno]=tfil; 341 np=p; *np++='\n'; /* shut off unterminated quoted string */ 342 while (--n>=0) *np++=')'; /* supply missing parens */ 343 pend=np; *np='\0'; if (plvl<0) plvl=0; 344 return(p); 345 } 346 if (trulvl || flslvl) 347 if (incomment) 348 pperror("unterminated comment"); 349 else 350 pperror("missing endif"); 351 inp=p; dump(); exit(exfail); 352 } 353 close(fin); fin=fins[--ifno]; dirs[0]=dirnams[ifno]; sayline(BACK); 354 } 355 } 356 } 357 358 #define BEG 0 359 #define LF 1 360 361 char * 362 cotoken(p) register char *p; { 363 register int c,i; char quoc; 364 static int state = BEG; 365 366 if (state!=BEG) goto prevlf; 367 for (;;) { 368 again: 369 while (!isspc(*p++)); 370 switch (*(inp=p-1)) { 371 case 0: { 372 if (eob(--p)) {p=refill(p); goto again;} 373 else ++p; /* ignore null byte */ 374 } break; 375 case '|': case '&': for (;;) {/* sloscan only */ 376 if (*p++== *inp) break; 377 if (eob(--p)) p=refill(p); 378 else break; 379 } break; 380 case '=': case '!': for (;;) {/* sloscan only */ 381 if (*p++=='=') break; 382 if (eob(--p)) p=refill(p); 383 else break; 384 } break; 385 case '<': case '>': for (;;) {/* sloscan only */ 386 if (*p++=='=' || p[-2]==p[-1]) break; 387 if (eob(--p)) p=refill(p); 388 else break; 389 } break; 390 case '\\': for (;;) { 391 if (*p++=='\n') {++lineno[ifno]; break;} 392 if (eob(--p)) p=refill(p); 393 else {++p; break;} 394 } break; 395 case '/': for (;;) { 396 if (*p++=='*') {/* comment */ 397 incomment++; 398 if (!passcom) {inp=p-2; dump(); ++flslvl;} 399 for (;;) { 400 while (!iscom(*p++)); 401 if (p[-1]=='*') for (;;) { 402 if (*p++=='/') goto endcom; 403 if (eob(--p)) { 404 if (!passcom) {inp=p; p=refill(p);} 405 else if ((p-inp)>=BUFSIZ) {/* split long comment */ 406 inp=p; p=refill(p); /* last char written is '*' */ 407 cputc('/',fout); /* terminate first part */ 408 /* and fake start of 2nd */ 409 outp=inp=p-=3; *p++='/'; *p++='*'; *p++='*'; 410 } else p=refill(p); 411 } else break; 412 } else if (p[-1]=='\n') { 413 ++lineno[ifno]; if (!passcom) putc('\n',fout); 414 } else if (eob(--p)) { 415 if (!passcom) {inp=p; p=refill(p);} 416 else if ((p-inp)>=BUFSIZ) {/* split long comment */ 417 inp=p; p=refill(p); 418 cputc('*',fout); cputc('/',fout); 419 outp=inp=p-=2; *p++='/'; *p++='*'; 420 } else p=refill(p); 421 } else ++p; /* ignore null byte */ 422 } 423 endcom: 424 incomment--; 425 if (!passcom) {outp=inp=p; --flslvl; goto again;} 426 break; 427 } 428 if (eob(--p)) p=refill(p); 429 else break; 430 } break; 431 # if gcos 432 case '`': 433 # endif 434 case '"': case '\'': { 435 quoc=p[-1]; 436 for (;;) { 437 while (!isquo(*p++)); 438 if (p[-1]==quoc) break; 439 if (p[-1]=='\n') {--p; break;} /* bare \n terminates quotation */ 440 if (p[-1]=='\\') for (;;) { 441 if (*p++=='\n') {++lineno[ifno]; break;} /* escaped \n ignored */ 442 if (eob(--p)) p=refill(p); 443 else {++p; break;} 444 } else if (eob(--p)) p=refill(p); 445 else ++p; /* it was a different quote character */ 446 } 447 } break; 448 case '\n': { 449 ++lineno[ifno]; if (isslo) {state=LF; return(p);} 450 prevlf: 451 state=BEG; 452 for (;;) { 453 if (*p++=='#') return(p); 454 if (eob(inp= --p)) p=refill(p); 455 else goto again; 456 } 457 } break; 458 case '0': case '1': case '2': case '3': case '4': 459 case '5': case '6': case '7': case '8': case '9': 460 for (;;) { 461 while (isnum(*p++)); 462 if (eob(--p)) p=refill(p); 463 else break; 464 } break; 465 case 'A': case 'B': case 'C': case 'D': case 'E': 466 case 'F': case 'G': case 'H': case 'I': case 'J': 467 case 'K': case 'L': case 'M': case 'N': case 'O': 468 case 'P': case 'Q': case 'R': case 'S': case 'T': 469 case 'U': case 'V': case 'W': case 'X': case 'Y': 470 case 'Z': case '_': 471 case 'a': case 'b': case 'c': case 'd': case 'e': 472 case 'f': case 'g': case 'h': case 'i': case 'j': 473 case 'k': case 'l': case 'm': case 'n': case 'o': 474 case 'p': case 'q': case 'r': case 's': case 't': 475 case 'u': case 'v': case 'w': case 'x': case 'y': 476 case 'z': 477 #if scw1 478 #define tmac1(c,bit) if (!xmac1(c,bit,&)) goto nomac 479 #define xmac1(c,bit,op) ((macbit+COFF)[c] op (bit)) 480 #else 481 #define tmac1(c,bit) 482 #define xmac1(c,bit,op) 483 #endif 484 485 #if scw2 486 #define tmac2(c0,c1,cpos) if (!xmac2(c0,c1,cpos,&)) goto nomac 487 #define xmac2(c0,c1,cpos,op)\ 488 ((macbit+COFF)[(t21+COFF)[c0]+(t22+COFF)[c1]] op (t23+COFF+cpos)[c0]) 489 #else 490 #define tmac2(c0,c1,cpos) 491 #define xmac2(c0,c1,cpos,op) 492 #endif 493 494 if (flslvl) goto nomac; 495 for (;;) { 496 c= p[-1]; tmac1(c,b0); 497 i= *p++; if (!isid(i)) goto endid; tmac1(i,b1); tmac2(c,i,0); 498 c= *p++; if (!isid(c)) goto endid; tmac1(c,b2); tmac2(i,c,1); 499 i= *p++; if (!isid(i)) goto endid; tmac1(i,b3); tmac2(c,i,2); 500 c= *p++; if (!isid(c)) goto endid; tmac1(c,b4); tmac2(i,c,3); 501 i= *p++; if (!isid(i)) goto endid; tmac1(i,b5); tmac2(c,i,4); 502 c= *p++; if (!isid(c)) goto endid; tmac1(c,b6); tmac2(i,c,5); 503 i= *p++; if (!isid(i)) goto endid; tmac1(i,b7); tmac2(c,i,6); 504 tmac2(i,0,7); 505 while (isid(*p++)); 506 if (eob(--p)) {refill(p); p=inp+1; continue;} 507 goto lokid; 508 endid: 509 if (eob(--p)) {refill(p); p=inp+1; continue;} 510 tmac2(p[-1],0,-1+(p-inp)); 511 lokid: 512 slookup(inp,p,0); if (newp) {p=newp; goto again;} 513 else break; 514 nomac: 515 while (isid(*p++)); 516 if (eob(--p)) {p=refill(p); goto nomac;} 517 else break; 518 } break; 519 } /* end of switch */ 520 521 if (isslo) return(p); 522 } /* end of infinite loop */ 523 } 524 525 char * 526 skipbl(p) register char *p; {/* get next non-blank token */ 527 do {outp=inp=p; p=cotoken(p);} while ((toktyp+COFF)[*inp]==BLANK); 528 return(p); 529 } 530 531 char * 532 unfill(p) register char *p; { 533 /* take <= BUFSIZ chars from right end of buffer and put them on instack . 534 /* slide rest of buffer to the right, update pointers, return new p. 535 */ 536 register char *np,*op; register int d; 537 if (mactop>=MAXFRE) { 538 pperror("%s: too much pushback",macnam); 539 p=inp=pend; dump(); /* begin flushing pushback */ 540 while (mactop>inctop[ifno]) {p=refill(p); p=inp=pend; dump();} 541 } 542 if (fretop>0) np=bufstack[--fretop]; 543 else { 544 np=malloc(BUFSIZ+1); 545 if (np==NULL) {pperror("no space"); exit(exfail);} 546 np[BUFSIZ]='\0'; 547 } 548 instack[mactop]=np; op=pend-BUFSIZ; if (op<p) op=p; 549 for (;;) {while (*np++= *op++); if (eob(op)) break;} /* out with old */ 550 endbuf[mactop++]=np; /* mark end of saved text */ 551 np=pbuf+BUFSIZ; op=pend-BUFSIZ; pend=np; if (op<p) op=p; 552 while (outp<op) *--np= *--op; /* slide over new */ 553 if (bob(np)) pperror("token too long"); 554 d=np-outp; outp+=d; inp+=d; macdam+=d; return(p+d); 555 } 556 557 char * 558 doincl(p) register char *p; { 559 int filok,inctype; 560 register char *cp; char **dirp,*nfil; char filname[BUFSIZ]; 561 562 p=skipbl(p); cp=filname; 563 if (*inp++=='<') {/* special <> syntax */ 564 inctype=1; 565 ++flslvl; /* prevent macro expansion */ 566 for (;;) { 567 outp=inp=p; p=cotoken(p); 568 if (*inp=='\n') {--p; *cp='\0'; break;} 569 if (*inp=='>') { *cp='\0'; break;} 570 # ifdef gimpel 571 if (*inp=='.' && !intss()) *inp='#'; 572 # endif 573 while (inp<p) *cp++= *inp++; 574 } 575 --flslvl; /* reenable macro expansion */ 576 } else if (inp[-1]=='"') {/* regular "" syntax */ 577 inctype=0; 578 # ifdef gimpel 579 while (inp<p) {if (*inp=='.' && !intss()) *inp='#'; *cp++= *inp++;} 580 # else 581 while (inp<p) *cp++= *inp++; 582 # endif 583 if (*--cp=='"') *cp='\0'; 584 } else {pperror("bad include syntax",0); inctype=2;} 585 /* flush current file to \n , then write \n */ 586 ++flslvl; do {outp=inp=p; p=cotoken(p);} while (*inp!='\n'); --flslvl; 587 inp=p; dump(); if (inctype==2) return(p); 588 /* look for included file */ 589 if (ifno+1 >=MAXINC) { 590 pperror("Unreasonable include nesting",0); return(p); 591 } 592 if((nfil=malloc(BUFSIZ))==NULL) {pperror("no space"); exit(exfail);} 593 filok=0; 594 for (dirp=dirs+inctype; *dirp; ++dirp) { 595 if ( 596 # if gcos 597 strdex(filname, '/') 598 # else 599 filname[0]=='/' 600 # endif 601 || **dirp=='\0') strcpy(nfil,filname); 602 else { 603 strcpy(nfil,*dirp); 604 # if unix || gcos 605 strcat(nfil,"/"); 606 # endif 607 #ifdef ibm 608 #ifndef gimpel 609 strcat(nfil,"."); 610 #endif 611 #endif 612 strcat(nfil,filname); 613 } 614 if (0<(fins[ifno+1]=open(nfil,READ))) { 615 filok=1; fin=fins[++ifno]; break; 616 } 617 } 618 if(filok==0){pperror("Can't find include file %s",filname);free(nfil);} 619 else { 620 nfil=realloc(nfil,strlen(nfil)+1); 621 lineno[ifno]=1; fnames[ifno]=nfil; 622 dirnams[ifno]=dirs[0]=trmdir(copy(nfil)); 623 sayline(START); 624 /* save current contents of buffer */ 625 while (!eob(p)) p=unfill(p); 626 inctop[ifno]=mactop; 627 } 628 return(p); 629 } 630 631 equfrm(a,p1,p2) register char *a,*p1,*p2; { 632 register char c; int flag; 633 c= *p2; *p2='\0'; 634 flag=strcmp(a,p1); *p2=c; return(flag==SAME); 635 } 636 637 char * 638 dodef(p) char *p; {/* process '#define' */ 639 register char *pin,*psav,*cf; 640 char **pf,**qf; int b,c,params; struct symtab *np; 641 char *oldval; 642 char *space, *newspace; 643 char *formal[MAXFRM]; /* formal[n] is name of nth formal */ 644 char formtxt[BUFSIZ]; /* space for formal names */ 645 646 ++flslvl; /* prevent macro expansion during 'define' */ 647 p=skipbl(p); pin=inp; 648 if ((toktyp+COFF)[*pin]!=IDENT) { 649 ppwarn("illegal macro name"); while (*inp!='\n') p=skipbl(p); return(p); 650 } 651 np=slookup(pin,p,1); 652 if (oldval=np->value) free(lastcopy); /* was previously defined */ 653 b=1; cf=pin; 654 while (cf<p) {/* update macbit */ 655 c= *cf++; xmac1(c,b,|=); b=(b+b)&0xFF; 656 if (cf!=p) xmac2(c,*cf,-1+(cf-pin),|=); 657 else xmac2(c,0,-1+(cf-pin),|=); 658 } 659 params=0; outp=inp=p; p=cotoken(p); pin=inp; 660 if (*pin=='(') {/* with parameters; identify the formals */ 661 cf=formtxt; pf=formal; 662 for (;;) { 663 p=skipbl(p); pin=inp; 664 if (*pin=='\n') { 665 --lineno[ifno]; --p; pperror("%s: missing )",np->name); break; 666 } 667 if (*pin==')') break; 668 if (*pin==',') continue; 669 if ((toktyp+COFF)[*pin]!=IDENT) { 670 c= *p; *p='\0'; pperror("bad formal: %s",pin); *p=c; 671 } else if (pf>= &formal[MAXFRM]) { 672 c= *p; *p='\0'; pperror("too many formals: %s",pin); *p=c; 673 } else { 674 *pf++=cf; while (pin<p) *cf++= *pin++; *cf++='\0'; ++params; 675 } 676 } 677 if (params==0) --params; /* #define foo() ... */ 678 } else if (*pin=='\n') {--lineno[ifno]; --p;} 679 /* remember beginning of macro body, so that we can 680 /* warn if a redefinition is different from old value. 681 */ 682 space=psav=malloc(BUFSIZ); 683 if (space==NULL) {pperror("too much defining"); return(p);} 684 *psav++ = '\0'; 685 for (;;) {/* accumulate definition until linefeed */ 686 outp=inp=p; p=cotoken(p); pin=inp; 687 if (*pin=='\\' && pin[1]=='\n') {putc('\n',fout); continue;} /* ignore escaped lf */ 688 if (*pin=='\n') break; 689 if (params) {/* mark the appearance of formals in the definiton */ 690 if ((toktyp+COFF)[*pin]==IDENT) { 691 for (qf=pf; --qf>=formal; ) { 692 if (equfrm(*qf,pin,p)) { 693 *psav++=qf-formal+1; *psav++=WARN; pin=p; break; 694 } 695 } 696 } else if (*pin=='"' || *pin=='\'' 697 # if gcos 698 || *pin=='`' 699 # endif 700 ) {/* inside quotation marks, too */ 701 char quoc= *pin; 702 for (*psav++= *pin++; pin<p && *pin!=quoc; ) { 703 while (pin<p && !isid(*pin)) *psav++= *pin++; 704 cf=pin; while (cf<p && isid(*cf)) ++cf; 705 for (qf=pf; --qf>=formal; ) { 706 if (equfrm(*qf,pin,cf)) { 707 *psav++=qf-formal+1; *psav++=WARN; pin=cf; break; 708 } 709 } 710 while (pin<cf) *psav++= *pin++; 711 } 712 } 713 } 714 while (pin<p) *psav++= *pin++; 715 } 716 *psav++=params; *psav++='\0'; 717 if ((cf=oldval)!=NULL) {/* redefinition */ 718 --cf; /* skip no. of params, which may be zero */ 719 while (*--cf); /* go back to the beginning */ 720 if (0!=strcmp(++cf,space+1)) {/* redefinition different from old */ 721 --lineno[ifno]; ppwarn("%s redefined",np->name); ++lineno[ifno]; 722 np->value=psav-1; 723 } else free(space); /* identical redef.; reclaim space */ 724 } else np->value=psav-1; 725 --flslvl; inp=pin; 726 if (np->value == psav-1) { 727 newspace = realloc(space, psav-space); 728 if (newspace==NULL) {pperror("no space"); exit(exfail);} 729 /* 730 * Adjust pointer in case this moved. 731 */ 732 np->value += newspace-space; 733 } 734 return(p); 735 } 736 737 #define fasscan() ptrtab=fastab+COFF 738 #define sloscan() ptrtab=slotab+COFF 739 740 char * 741 control(p) register char *p; {/* find and handle preprocessor control lines */ 742 register struct symtab *np; 743 for (;;) { 744 fasscan(); p=cotoken(p); if (*inp=='\n') ++inp; dump(); 745 sloscan(); p=skipbl(p); 746 *--inp=SALT; outp=inp; ++flslvl; np=slookup(inp,p,0); --flslvl; 747 if (np==defloc) {/* define */ 748 if (flslvl==0) {p=dodef(p); continue;} 749 } else if (np==incloc) {/* include */ 750 if (flslvl==0) {p=doincl(p); continue;} 751 } else if (np==ifnloc) {/* ifndef */ 752 ++flslvl; p=skipbl(p); np=slookup(inp,p,0); --flslvl; 753 if (flslvl==0 && np->value==0) ++trulvl; 754 else ++flslvl; 755 } else if (np==ifdloc) {/* ifdef */ 756 ++flslvl; p=skipbl(p); np=slookup(inp,p,0); --flslvl; 757 if (flslvl==0 && np->value!=0) ++trulvl; 758 else ++flslvl; 759 } else if (np==eifloc) {/* endif */ 760 if (flslvl) {if (--flslvl==0) sayline(CONT);} 761 else if (trulvl) --trulvl; 762 else pperror("If-less endif",0); 763 } else if (np==elsloc) {/* else */ 764 if (flslvl) { 765 if (--flslvl!=0) ++flslvl; 766 else {++trulvl; sayline(CONT);} 767 } 768 else if (trulvl) {++flslvl; --trulvl;} 769 else pperror("If-less else",0); 770 } else if (np==udfloc) {/* undefine */ 771 if (flslvl==0) { 772 ++flslvl; p=skipbl(p); slookup(inp,p,DROP); --flslvl; 773 } 774 } else if (np==ifloc) {/* if */ 775 #if tgp 776 pperror(" IF not implemented, true assumed", 0); 777 if (flslvl==0) ++trulvl; else ++flslvl; 778 #else 779 newp=p; 780 if (flslvl==0 && yyparse()) ++trulvl; else ++flslvl; 781 p=newp; 782 #endif 783 } else if (np==lneloc) {/* line */ 784 if (flslvl==0 && pflag==0) { 785 char *savestring(); 786 char filename[BUFSIZ], *cp = filename; 787 outp=inp=p; *--outp='#'; 788 /* Find the line number.. */ 789 do { 790 p = cotoken(p); 791 } while (!isnum(*inp) && *inp != '\n'); 792 if (isnum(*inp)) 793 lineno[ifno] = atoi(inp)-1; 794 /* Skip over the blank token */ 795 inp = p; 796 if (*inp != '\n') { 797 p = cotoken(p); inp = p; 798 } 799 /* Add a quote if missing.. */ 800 if (*inp != '\n') { 801 p = cotoken(p); 802 /* Add a quote if missing.. */ 803 if (*inp == '"') 804 inp++; 805 else { 806 dump(); 807 *--outp = '"'; 808 } 809 while (*inp != '\n') { 810 while (inp < p && *inp != '"' && 811 cp < filename+sizeof(filename)) 812 *cp++ = *inp++; 813 if (*inp == '"') 814 break; 815 inp = p; p = cotoken(p); 816 } 817 fnames[ifno] = savestring(filename, cp); 818 /* Add a quote if missing.. */ 819 if (*inp != '"') { 820 dump(); 821 *--outp = '"'; 822 } 823 } 824 while (*inp != '\n') 825 p = cotoken(p); 826 continue; 827 } 828 } else if (np==identloc) {/* ident (for Sys 5r3 compat) */ 829 while(*inp!='\n') p=cotoken(p); 830 } else if (*++inp=='\n') outp=inp; /* allows blank line after # */ 831 else pperror("undefined control",0); 832 /* flush to lf */ 833 ++flslvl; while (*inp!='\n') {outp=inp=p; p=cotoken(p);} --flslvl; 834 } 835 } 836 837 char * 838 savestring(start, finish) 839 register char *start, *finish; 840 { 841 char *retbuf; 842 register char *cp; 843 844 retbuf = (char *) calloc(finish - start + 1, sizeof (char)); 845 cp = retbuf; 846 while (start < finish) 847 *cp++ = *start++; 848 *cp = 0; 849 return(retbuf); 850 } 851 852 struct symtab * 853 stsym(s) register char *s; { 854 char buf[BUFSIZ]; register char *p; 855 856 /* make definition look exactly like end of #define line */ 857 /* copy to avoid running off end of world when param list is at end */ 858 p=buf; while (*p++= *s++); 859 p=buf; while (isid(*p++)); /* skip first identifier */ 860 if (*--p=='=') {*p++=' '; while (*p++);} 861 else {s=" 1"; while (*p++= *s++);} 862 pend=p; *--p='\n'; 863 sloscan(); dodef(buf); return(lastsym); 864 } 865 866 struct symtab * 867 ppsym(s) char *s; {/* kluge */ 868 register struct symtab *sp; 869 register char *name; 870 871 cinit=SALT; sp=stsym(s); name = malloc(strlen(sp->name)+1+1); 872 name[0] = '#'; strcpy(name+1, sp->name); sp->name = name; 873 cinit=0; return(sp); 874 } 875 876 /* VARARGS1 */ 877 pperror(s,x,y) char *s; { 878 if (fnames[ifno][0]) fprintf(stderr, 879 # if gcos 880 "*%c* \"%s\", line ", exfail >= 0 ? 'F' : 'W', 881 # else 882 "%s: ", 883 # endif 884 fnames[ifno]); 885 fprintf(stderr, "%d: ",lineno[ifno]); 886 fprintf(stderr, s, x, y); 887 fprintf(stderr,"\n"); 888 ++exfail; 889 } 890 891 yyerror(s,a,b) char *s; { 892 pperror(s,a,b); 893 } 894 895 ppwarn(s,x) char *s; { 896 int fail = exfail; 897 exfail = -1; 898 pperror(s,x); 899 exfail = fail; 900 } 901 902 struct symtab * 903 lookup(namep, enterf) 904 char *namep; 905 { 906 register char *np, *snp; 907 register int c, i; int around; 908 register struct symtab *sp; 909 910 /* namep had better not be too long (currently, <=NCPS chars) */ 911 np=namep; around=0; i=cinit; 912 while (c= *np++) i += i+c; c=i; /* c=i for register usage on pdp11 */ 913 c %= symsiz; if (c<0) c += symsiz; 914 sp = &stab[c]; 915 while (snp=sp->name) { 916 np = namep; 917 while (*snp++ == *np) if (*np++ == '\0') { 918 if (enterf==DROP) {sp->name[0]= DROP; sp->value=0;} 919 return(lastsym=sp); 920 } 921 if (--sp < &stab[0]) 922 if (around) {pperror("too many defines", 0); exit(exfail);} 923 else {++around; sp = &stab[symsiz-1];} 924 } 925 if (enterf==1) sp->name=namep; 926 return(lastsym=sp); 927 } 928 929 struct symtab * 930 slookup(p1,p2,enterf) register char *p1,*p2; int enterf;{ 931 register char *p3; char c2,c3; struct symtab *np; 932 c2= *p2; *p2='\0'; /* mark end of token */ 933 if ((p2-p1)>NCPS) p3=p1+NCPS; else p3=p2; 934 c3= *p3; *p3='\0'; /* truncate to NCPS chars or less */ 935 if (enterf==1) p1=copy(p1); 936 np=lookup(p1,enterf); *p3=c3; *p2=c2; 937 if (np->value!=0 && flslvl==0) newp=subst(p2,np); 938 else newp=0; 939 return(np); 940 } 941 942 char * 943 subst(p,sp) register char *p; struct symtab *sp; { 944 static char match[]="%s: argument mismatch"; 945 register char *ca,*vp; int params; 946 char *actual[MAXFRM]; /* actual[n] is text of nth actual */ 947 char actused[MAXFRM]; /* for newline processing in actuals */ 948 char acttxt[BUFSIZ]; /* space for actuals */ 949 int nlines = 0; 950 951 if (0==(vp=sp->value)) return(p); 952 if ((p-macforw)<=macdam) { 953 if (++maclvl>symsiz && !rflag) { 954 pperror("%s: macro recursion",sp->name); return(p); 955 } 956 } else maclvl=0; /* level decreased */ 957 macforw=p; macdam=0; /* new target for decrease in level */ 958 macnam=sp->name; 959 dump(); 960 if (sp==ulnloc) { 961 vp=acttxt; *vp++='\0'; 962 sprintf(vp,"%d",lineno[ifno]); while (*vp++); 963 } else if (sp==uflloc) { 964 vp=acttxt; *vp++='\0'; 965 sprintf(vp,"\"%s\"",fnames[ifno]); while (*vp++); 966 } 967 if (0!=(params= *--vp&0xFF)) {/* definition calls for params */ 968 register char **pa; 969 ca=acttxt; pa=actual; 970 if (params==0xFF) params=1; /* #define foo() ... */ 971 sloscan(); ++flslvl; /* no expansion during search for actuals */ 972 plvl= -1; 973 do p=skipbl(p); while (*inp=='\n'); /* skip \n too */ 974 if (*inp=='(') { 975 maclin=lineno[ifno]; macfil=fnames[ifno]; 976 for (plvl=1; plvl!=0; ) { 977 *ca++='\0'; 978 for (;;) { 979 outp=inp=p; p=cotoken(p); 980 if (*inp=='(') ++plvl; 981 if (*inp==')' && --plvl==0) {--params; break;} 982 if (plvl==1 && *inp==',') {--params; break;} 983 while (inp<p) *ca++= *inp++; 984 if (ca> &acttxt[BUFSIZ]) 985 pperror("%s: actuals too long",sp->name); 986 } 987 if (pa>= &actual[MAXFRM]) ppwarn(match,sp->name); 988 else { actused[pa-actual]=0; *pa++=ca; } 989 } 990 nlines = lineno[ifno] - maclin; 991 lineno[ifno] = maclin; /* don't count newlines here */ 992 } 993 if (params!=0) ppwarn(match,sp->name); 994 while (--params>=0) *pa++=""+1; /* null string for missing actuals */ 995 --flslvl; fasscan(); 996 } 997 for (;;) {/* push definition onto front of input stack */ 998 while (!iswarn(*--vp)) { 999 if (bob(p)) {outp=inp=p; p=unfill(p);} 1000 *--p= *vp; 1001 } 1002 if (*vp==warnc) {/* insert actual param */ 1003 ca=actual[*--vp-1]; 1004 while (*--ca) { 1005 if (bob(p)) {outp=inp=p; p=unfill(p);} 1006 /* Actuals with newlines confuse line numbering */ 1007 if (*ca == '\n' && actused[*vp-1]) 1008 if (*(ca-1) == '\\') ca--; 1009 else *--p = ' '; 1010 else { *--p= *ca; if (*ca == '\n') nlines--; } 1011 } 1012 actused[*vp-1] = 1; 1013 } else { 1014 if (nlines > 0 ) 1015 while (nlines-- > 0) 1016 *--p = '\n'; 1017 break; 1018 } 1019 } 1020 outp=inp=p; 1021 return(p); 1022 } 1023 1024 1025 1026 1027 char * 1028 trmdir(s) register char *s; { 1029 register char *p = s; 1030 while (*p++); --p; while (p>s && *--p!='/'); 1031 # if unix 1032 if (p==s) *p++='.'; 1033 # endif 1034 *p='\0'; 1035 return(s); 1036 } 1037 1038 STATIC char * 1039 copy(s) register char *s; { 1040 register char *old; 1041 1042 old = malloc(strlen(s)+1); 1043 if (old==NULL) {pperror("no space"); exit(exfail);} 1044 strcpy(old, s); 1045 return(lastcopy=old); 1046 } 1047 1048 char * 1049 strdex(s,c) char *s,c; { 1050 while (*s) if (*s++==c) return(--s); 1051 return(0); 1052 } 1053 1054 yywrap(){ return(1); } 1055 1056 main(argc,argv) 1057 char *argv[]; 1058 { 1059 register int i,c; 1060 register char *p; 1061 char *tf,**cp2; 1062 1063 # if gcos 1064 if (setjmp(env)) return (exfail); 1065 # endif 1066 p="_$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 1067 i=0; 1068 while (c= *p++) { 1069 (fastab+COFF)[c] |= IB|NB|SB; (toktyp+COFF)[c]=IDENT; 1070 #if scw2 1071 /* 53 == 63-10; digits rarely appear in identifiers, 1072 /* and can never be the first char of an identifier. 1073 /* 11 == 53*53/sizeof(macbit) . 1074 */ 1075 ++i; (t21+COFF)[c]=(53*i)/11; (t22+COFF)[c]=i%11; 1076 #endif 1077 } 1078 p="0123456789."; 1079 while (c= *p++) {(fastab+COFF)[c] |= NB|SB; (toktyp+COFF)[c]=NUMBR;} 1080 # if gcos 1081 p="\n\"'`/\\"; 1082 # else 1083 p="\n\"'/\\"; 1084 # endif 1085 while (c= *p++) (fastab+COFF)[c] |= SB; 1086 # if gcos 1087 p="\n\"'`\\"; 1088 # else 1089 p="\n\"'\\"; 1090 # endif 1091 while (c= *p++) (fastab+COFF)[c] |= QB; 1092 p="*\n"; while (c= *p++) (fastab+COFF)[c] |= CB; 1093 (fastab+COFF)[warnc] |= WB; 1094 (fastab+COFF)['\0'] |= CB|QB|SB|WB; 1095 for (i=ALFSIZ; --i>=0; ) slotab[i]=fastab[i]|SB; 1096 p=" \t\013\f\r"; /* note no \n; \v not legal for vertical tab? */ 1097 while (c= *p++) (toktyp+COFF)[c]=BLANK; 1098 #if scw2 1099 for ((t23+COFF)[i=ALFSIZ+7-COFF]=1; --i>=-COFF; ) 1100 if (((t23+COFF)[i]=(t23+COFF+1)[i]<<1)==0) (t23+COFF)[i]=1; 1101 #endif 1102 1103 # if unix 1104 fnames[ifno=0] = ""; dirnams[0]=dirs[0]="."; 1105 # endif 1106 # if ibm 1107 fnames[ifno=0] = ""; 1108 # endif 1109 # if gcos 1110 if (inquire(stdin, _TTY)) freopen("*src", "rt", stdin); 1111 # endif 1112 # if gimpel || gcos 1113 fnames[ifno=0] = (char *)inquire(stdin, _FILENAME); 1114 dirnams[0] = dirs[0] = trmdir(copy(fnames[0])); 1115 # endif 1116 for(i=1; i<argc; i++) 1117 { 1118 switch(argv[i][0]) 1119 { 1120 case '-': 1121 # if gcos 1122 switch(toupper(argv[i][1])) { /* case-independent on GCOS */ 1123 # else 1124 switch(argv[i][1]) { 1125 # endif 1126 case 'M': mflag++; 1127 case 'P': pflag++; 1128 case 'E': continue; 1129 case 'R': ++rflag; continue; 1130 case 'C': passcom++; continue; 1131 case 'D': 1132 if (predef>prespc+NPREDEF) { 1133 pperror("too many -D options, ignoring %s",argv[i]); 1134 continue; 1135 } 1136 /* ignore plain "-D" (no argument) */ 1137 if (*(argv[i]+2)) *predef++ = argv[i]+2; 1138 continue; 1139 case 'U': 1140 if (prund>punspc+NPREDEF) { 1141 pperror("too many -U options, ignoring %s",argv[i]); 1142 continue; 1143 } 1144 *prund++ = argv[i]+2; 1145 continue; 1146 case 'I': 1147 if (nd>8) pperror("excessive -I file (%s) ignored",argv[i]); 1148 else dirs[nd++] = argv[i]+2; 1149 continue; 1150 case '\0': continue; 1151 default: 1152 pperror("unknown flag %s", argv[i]); 1153 continue; 1154 } 1155 default: 1156 if (fin==FIRSTOPEN) { 1157 if (0>(fin=open(argv[i], READ))) { 1158 pperror("No source file %s",argv[i]); exit(8); 1159 } 1160 fnames[ifno]=copy(argv[i]); 1161 infile=copy(argv[i]); 1162 dirs[0]=dirnams[ifno]=trmdir(argv[i]); 1163 # ifndef gcos 1164 /* too dangerous to have file name in same syntactic position 1165 be input or output file depending on file redirections, 1166 so force output to stdout, willy-nilly 1167 [i don't see what the problem is. jfr] 1168 */ 1169 } else if (fout==stdout) { 1170 if (NULL==(fout=fopen(argv[i], "w"))) { 1171 pperror("Can't create %s", argv[i]); exit(8); 1172 } else fclose(stdout); 1173 # endif 1174 } else pperror("extraneous name %s", argv[i]); 1175 } 1176 } 1177 if (fin == FIRSTOPEN) 1178 fin = STDIN; 1179 1180 if (mflag) { 1181 if (infile==(char *)0) { 1182 fprintf(stderr, 1183 "no input file specified with -M flag\n"); 1184 exit(8); 1185 } 1186 tf=(char *)rindex(infile, '.'); 1187 if (tf==0) { 1188 fprintf(stderr, "missing component name on %s\n", 1189 infile); 1190 exit(8); 1191 } 1192 tf[1]='o'; 1193 tf=(char *)rindex(infile, '/'); 1194 if (tf!=(char *)0) 1195 infile = tf + 1; 1196 mout=fout; 1197 if (NULL==(fout=fopen("/dev/null", "w"))) { 1198 pperror("Can't open /dev/null"); 1199 exit(8); 1200 } 1201 } 1202 fins[ifno]=fin; 1203 exfail = 0; 1204 /* after user -I files here are the standard include libraries */ 1205 # if unix 1206 dirs[nd++] = "/usr/include"; 1207 # endif 1208 # if gcos 1209 dirs[nd++] = "cc/include"; 1210 # endif 1211 # if ibm 1212 # ifndef gimpel 1213 dirs[nd++] = "BTL$CLIB"; 1214 # endif 1215 # endif 1216 # ifdef gimpel 1217 dirs[nd++] = intss() ? "SYS3.C." : "" ; 1218 # endif 1219 /* dirs[nd++] = "/compool"; */ 1220 dirs[nd++] = 0; 1221 defloc=ppsym("define"); 1222 udfloc=ppsym("undef"); 1223 incloc=ppsym("include"); 1224 elsloc=ppsym("else"); 1225 eifloc=ppsym("endif"); 1226 ifdloc=ppsym("ifdef"); 1227 ifnloc=ppsym("ifndef"); 1228 ifloc=ppsym("if"); 1229 lneloc=ppsym("line"); 1230 identloc=ppsym("ident"); /* Sys 5r3 compatibility */ 1231 for (i=sizeof(macbit)/sizeof(macbit[0]); --i>=0; ) macbit[i]=0; 1232 # if unix 1233 ysysloc=stsym("unix"); 1234 # endif 1235 # if gcos 1236 ysysloc=stsym ("gcos"); 1237 # endif 1238 # if ibm 1239 ysysloc=stsym ("ibm"); 1240 # endif 1241 # if pdp11 1242 varloc=stsym("pdp11"); 1243 # endif 1244 # if vax 1245 varloc=stsym("vax"); 1246 # endif 1247 # if interdata 1248 varloc=stsym ("interdata"); 1249 # endif 1250 # if tss 1251 varloc=stsym ("tss"); 1252 # endif 1253 # if os 1254 varloc=stsym ("os"); 1255 # endif 1256 # if mert 1257 varloc=stsym ("mert"); 1258 # endif 1259 # if mc68000 1260 varloc=stsym("mc68000"); 1261 # endif 1262 # if sun 1263 varloc=stsym("sun"); 1264 # endif 1265 ulnloc=stsym ("__LINE__"); 1266 uflloc=stsym ("__FILE__"); 1267 1268 tf=fnames[ifno]; fnames[ifno]="command line"; lineno[ifno]=1; 1269 cp2=prespc; 1270 while (cp2<predef) stsym(*cp2++); 1271 cp2=punspc; 1272 while (cp2<prund) { 1273 if (p=strdex(*cp2, '=')) *p++='\0'; 1274 lookup(*cp2++, DROP); 1275 } 1276 fnames[ifno]=tf; 1277 pbeg=buffer+NCPS; pbuf=pbeg+BUFSIZ; pend=pbuf+BUFSIZ; 1278 1279 trulvl = 0; flslvl = 0; 1280 lineno[0] = 1; sayline(START); 1281 outp=inp=pend; 1282 control(pend); 1283 return (exfail); 1284 } 1285