14887Schin /***********************************************************************
24887Schin * *
34887Schin * This software is part of the ast package *
4*10898Sroland.mainz@nrubsig.org * Copyright (c) 1986-2009 AT&T Intellectual Property *
54887Schin * and is licensed under the *
64887Schin * Common Public License, Version 1.0 *
78462SApril.Chin@Sun.COM * by AT&T Intellectual Property *
84887Schin * *
94887Schin * A copy of the License is available at *
104887Schin * http://www.opensource.org/licenses/cpl1.0.txt *
114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
124887Schin * *
134887Schin * Information and Software Systems Research *
144887Schin * AT&T Research *
154887Schin * Florham Park NJ *
164887Schin * *
174887Schin * Glenn Fowler <gsf@research.att.com> *
184887Schin * *
194887Schin ***********************************************************************/
204887Schin #pragma prototyped
214887Schin /*
224887Schin * Glenn Fowler
234887Schin * AT&T Research
244887Schin *
254887Schin * common preprocessor macro reference handler
264887Schin */
274887Schin
284887Schin #include "pplib.h"
294887Schin
304887Schin void
ppmacref(struct ppsymbol * sym,char * file,int line,int type,unsigned long sum)314887Schin ppmacref(struct ppsymbol* sym, char* file, int line, int type, unsigned long sum)
324887Schin {
334887Schin register char* p;
344887Schin
354887Schin NoP(file);
364887Schin NoP(line);
374887Schin p = (pp.state & (DIRECTIVE|JOINING)) == DIRECTIVE ? pp.outp : pp.addp;
384887Schin p += sfsprintf(p, MAXTOKEN, "\n#%s %d", pp.lineid, error_info.line);
394887Schin p += sfsprintf(p, MAXTOKEN, "\n#%s %s:%s %s %d", dirname(PRAGMA), pp.pass, keyname(X_MACREF), sym->name, type);
404887Schin if (type > 0)
414887Schin {
424887Schin if (sym->macro && sym->macro->value)
434887Schin sum = strsum(sym->macro->value, (long)sym->macro->arity);
444887Schin p += sfsprintf(p, MAXTOKEN, " %lu", sum);
454887Schin }
464887Schin if ((pp.state & (DIRECTIVE|JOINING)) == DIRECTIVE)
474887Schin {
484887Schin pp.outp = p;
494887Schin ppcheckout();
504887Schin }
514887Schin else
524887Schin {
534887Schin *p++ = '\n';
544887Schin pp.addp = p;
554887Schin pp.state |= ADD;
564887Schin }
574887Schin pp.pending = pppendout();
584887Schin }
59