⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpp.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 4 页
字号:
	if (enterf==1) p1=copy(p1);	np=lookup(p1,enterf); *p3=c3; *p2=c2;	if (np->value!=0 && flslvl==0) newp=subst(p2,np);	else newp=0;	return(np);}char *subst(p,sp) register char *p; register struct symtab *sp; {	static char match[]="%s: argument mismatch";	register char *ca,*vp; register int params;	char *actual[MAXFRM]; /* actual[n] is text of nth actual   */	char actused[MAXFRM]; /* for newline processing in actuals */	char acttxt[BUFSIZ];  /* space for actuals */	register int  nlines = 0;	if (0==(vp=sp->value)) return(p);	if ((p-macforw)<=macdam) {		if (++maclvl>symsiz && !rflag) {			pperror("%s: macro recursion",sp->name); return(p);		}	} else maclvl=0;	/* level decreased */	macforw=p; macdam=0;	/* new target for decrease in level */	macnam=sp->name;	dump();	if (sp==ulnloc) {		vp=acttxt; *vp++='\0';		sprintf(vp,"%d",lineno[ifno]); while (*vp++);	} else if (sp==uflloc) {		vp=acttxt; *vp++='\0';		sprintf(vp,"\"%s\"",fnames[ifno]); while (*vp++);	}	if (0!=(params= *--vp&0xFF)) {/* definition calls for params */		register char **pa;		ca=acttxt; pa=actual;		if (params==0xFF) params=1;	/* #define foo() ... */		sloscan(); ++flslvl; /* no expansion during search for actuals */		plvl= -1;		do {			p=skipbl(p); /* * 007 - copy \n between macro name and ( */			if (*inp=='\n') {				++lineno[ifno];				putc('\n', fout);			}		} while (*inp=='\n');		/* For bug #2136 */		maclin=lineno[ifno]; macfil=fnames[ifno]; /* LFL 3-9-88 */		if (*inp=='(') {			for (plvl=1; plvl!=0; ) {				*ca++='\0';				for (;;) {					outp=inp=p; p=cotoken(p);					if (*inp=='(') ++plvl;					if (*inp==')' && --plvl==0) {--params; break;}					if (plvl==1 && *inp==',') {--params; break;}					while (inp<p) *ca++= *inp++;					if (ca> &acttxt[BUFSIZ])						pperror("%s: actuals too long",sp->name);				}				if (pa>= &actual[MAXFRM]) ppwarn(match,sp->name);				else { actused[pa-actual]=0; *pa++=ca; }			}			nlines = lineno[ifno] - maclin;			lineno[ifno] = maclin; /* don't count newlines here */		}		if (params!=0) ppwarn(match,sp->name);		while (--params>=0) *pa++=""+1;	/* null string for missing actuals */		--flslvl; fasscan();	}	for (;;) {/* push definition onto front of input stack */		while (!iswarn(*--vp)) {			if (bob(p)) {outp=inp=p; p=unfill(p);}			*--p= *vp;		}		if (*vp==warnc) {/* insert actual param */			ca=actual[*--vp-1];			while (*--ca) {				if (bob(p)) {outp=inp=p; p=unfill(p);}				/* Actuals with newlines confuse line numbering */				if (*ca == '\n' && actused[*vp-1])					if (*(ca-1) == '\\') ca--;					else *--p = ' ';				else { *--p= *ca; if (*ca == '\n') nlines--; }			}			actused[*vp-1] = 1;		} else {			if (nlines > 0 )				while (nlines-- > 0)					*--p = '\n';			break;		}	}	outp=inp=p;	return(p);}char *trmdir(s) register char *s; {	register char *p = s;	while (*p++); --p; while (p>s && *--p!='/');# if unix	if (p==s) *p++='.';# endif	*p='\0';	return(s);}STATIC char *copy(s) register char *s; {	register char *old;	old = malloc(strlen(s)+1);	if (old==NULL) {pperror("no space"); exit(exfail);}	strcpy(old, s);	return(lastcopy=old);}char *strdex(s,c) char *s,c; {	while (*s) if (*s++==c) return(--s);	return(0);}yywrap(){ return(1); }main(argc,argv)	char *argv[];{	register int i,c;	register char *p;	char *tf,**cp2;	int inc_std = 1; /* include standard directories in the search path */# if gcos	if (setjmp(env)) return (exfail);# endif	p="_$ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";		i=0;		while (c= *p++) {			(fastab+COFF)[c] |= IB|NB|SB; (toktyp+COFF)[c]=IDENT;#if scw2			/* 53 == 63-10; digits rarely appear in identifiers,			/* and can never be the first char of an identifier.			/* 11 == 53*53/sizeof(macbit) .			*/			++i; (t21+COFF)[c]=(53*i)/11; (t22+COFF)[c]=i%11;#endif		}	p="0123456789.";		while (c= *p++) {(fastab+COFF)[c] |= NB|SB; (toktyp+COFF)[c]=NUMBR;}# if gcos	p="\n\"'`/\\";# else	p="\n\"'/\\";# endif		while (c= *p++) (fastab+COFF)[c] |= SB;# if gcos	p="\n\"'`\\";# else	p="\n\"'\\";# endif		while (c= *p++) (fastab+COFF)[c] |= QB;	p="*\n"; while (c= *p++) (fastab+COFF)[c] |= CB;	(fastab+COFF)[warnc] |= WB;	(fastab+COFF)['\0'] |= CB|QB|SB|WB;	for (i=ALFSIZ; --i>=0; ) slotab[i]=fastab[i]|SB;	p=" \t\013\f\r";	/* note no \n;	\v not legal for vertical tab? */		while (c= *p++) (toktyp+COFF)[c]=BLANK;#if scw2	for ((t23+COFF)[i=ALFSIZ+7-COFF]=1; --i>=-COFF; )		if (((t23+COFF)[i]=(t23+COFF+1)[i]<<1)==0) (t23+COFF)[i]=1;#endif# if unix	fnames[ifno=0] = ""; dirnams[0]=dirs[0]=".";# endif# if ibm	fnames[ifno=0] = "";# endif# if gcos	if (inquire(stdin, _TTY)) freopen("*src", "rt", stdin);# endif# if gimpel || gcos	fnames[ifno=0] = (char *)inquire(stdin, _FILENAME);	dirnams[0] = dirs[0] = trmdir(copy(fnames[0]));# endif	for(i=1; i<argc; i++)		{		switch(argv[i][0])			{			case '-':# if gcos			switch(toupper(argv[i][1])) { /* case-independent on GCOS */# else			switch(argv[i][1]) {# endif				case 'M': mflag++;				case 'P': pflag++;				case 'E': 					/* -Em switch for makefile 					 * dependencies - vdp05					  */ 					if (argv[i][2] == 'm')	 	 					 	mflag++ ;					else 						continue;				case 'R': ++rflag; continue;				case 'C': passcom++; continue;				case 'B': eolcom++; continue;				case 'D':					if (predef>prespc+NPREDEF) {						pperror("too many -D options, ignoring %s",argv[i]);						continue;					}					/* ignore plain "-D" (no argument) */					if (*(argv[i]+2)) *predef++ = argv[i]+2;					continue;				case 'U':					if (prund>punspc+NPREDEF) {						pperror("too many -U options, ignoring %s",argv[i]);						continue;					}					*prund++ = argv[i]+2;					continue;				case 'I':					/*					 * Leave room for two "standard"					 * include directories and a NULL					 */					if (nd >= (MAXIDIRS-3))					    pperror(					      "excessive -I file (%s) ignored",					      argv[i]);					else if (argv[i][2] == '\0')					    inc_std = 0; /* no std dirs */					else dirs[nd++] = argv[i]+2;					continue;				case '\0': continue;				case 'v': continue;				case 'm':					if (strcmp (argv[i], "-mips2") == 0)					    continue;				default: 					pperror("unknown flag %s", argv[i]);					continue;				}			default:				if (fin==FIRSTOPEN) {					if (0>(fin=open(argv[i], READ))) {						pperror("No source file %s",argv[i]); exit(8);					}					fnames[ifno]=copy(argv[i]);					infile=copy(argv[i]);					dirs[0]=dirnams[ifno]=trmdir(argv[i]);# ifndef gcos/* too dangerous to have file name in same syntactic position   be input or output file depending on file redirections,   so force output to stdout, willy-nilly	[i don't see what the problem is.  jfr]*/				} else if (fout==stdout) {					if (NULL==(fout=fopen(argv[i], "w"))) {						pperror("Can't create %s", argv[i]); exit(8);					} else fclose(stdout);# endif				} else pperror("extraneous name %s", argv[i]);			}		}	if (fin == FIRSTOPEN)		fin = STDIN;	if (mflag) {		if (infile==(char *)0) {			fprintf(stderr,				"no input file specified with -M flag\n");			exit(8);		}		tf=(char *)rindex(infile, '.');		if (tf==0) {			fprintf(stderr, "missing component name on %s\n",				infile);			exit(8);		}		tf[1]='o';		tf=(char *)rindex(infile, '/');		if (tf!=(char *)0)			infile = tf + 1;		mout=fout;		if (NULL==(fout=fopen("/dev/null", "w"))) {			pperror("Can't open /dev/null");			exit(8);		}	}	fins[ifno]=fin;	exfail = 0;		/* after user -I files here are the standard include libraries */# if unix#  if defined(CROSS) || defined(MOXIE)	if (inc_std)	  dirs[nd++] = "/usr/local/mips/include";#  else	if (inc_std) {	  dirs[nd++] = "/usr/include";	}#  endif# endif# if gcos	dirs[nd++] = "cc/include";# endif# if ibm# ifndef gimpel	dirs[nd++] = "BTL$CLIB";# endif# endif# ifdef gimpel	dirs[nd++] = intss() ?  "SYS3.C." : "" ;# endif	/* dirs[nd++] = "/compool"; */	dirs[nd++] = 0;	defloc=ppsym("define");	udfloc=ppsym("undef");	incloc=ppsym("include");	elsloc=ppsym("else");	eifloc=ppsym("endif");	ifdloc=ppsym("ifdef");	ifnloc=ppsym("ifndef");	ifloc=ppsym("if");	eliloc=ppsym("elif");	lneloc=ppsym("line");	identloc=ppsym("ident");	/* Sys 5r3 compatibility */        pragmaloc=ppsym("pragma"); 	for (i=sizeof(macbit)/sizeof(macbit[0]); --i>=0; ) macbit[i]=0;# if unix	ysysloc=stsym("unix");# endif#if bsd4_2	ysysloc=stsym("bsd4_2");		/* aps001 */#endif#if ultrix	ysysloc=stsym("ultrix");		/* aps001 */#endif# if mips	varloc=stsym("mips");# endif# if MIPSEL	varloc=stsym("MIPSEL");# endif# if host_mips	varloc=stsym("host_mips");# endif# if gcos	ysysloc=stsym ("gcos");# endif# if ibm	ysysloc=stsym ("ibm");# endif# if pdp11	varloc=stsym("pdp11");# endif# if vax	varloc=stsym("vax");# endif# if interdata	varloc=stsym ("interdata");# endif# if tss	varloc=stsym ("tss");# endif# if os	varloc=stsym ("os");# endif# if mert	varloc=stsym ("mert");# endif# if mc68000	varloc=stsym("mc68000");# endif# if sun	varloc=stsym("sun");# endif	ulnloc=stsym ("__LINE__");	uflloc=stsym ("__FILE__");	tf=fnames[ifno]; fnames[ifno]="command line"; lineno[ifno]=1;	cp2=prespc;	while (cp2<predef) stsym(*cp2++);	cp2=punspc;	while (cp2<prund) {		if (p=strdex(*cp2, '=')) *p++='\0';		lookup(*cp2++, DROP);	}	pascal_file = (lookup("LANGUAGE_PASCAL",0)->value != 0); /* 3-9-88 */	if (pascal_file) {	  (fastab+COFF)['{'] |= SB;	  (fastab+COFF)['('] |= SB;	}	fnames[ifno]=tf;	pbeg=buffer+NCPS; pbuf=pbeg+BUFSIZ; pend=pbuf+BUFSIZ;	trulvl = 0; flslvl = 0;	lineno[0] = 1; sayline(START);	outp=inp=pend;	control(pend);	return (exfail);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -