/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1986-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* preprocessor macro call
*/
#include "pplib.h"
#include <ctype.h>
/*
* call a macro by pushing its value on the input stream
* only the macro token itself has been consumed
* -1 returned if macro disabled
* 0 returned if tok==0 and sym->mac->value to be copied to output by caller
* 1 returned if value pushed on input
*/
int
{
register int c;
register char* p;
register char* q;
int n;
int m;
int ret;
int old_hidden;
int last_line;
long old_state;
char* last_file;
char* old_next;
char* old_token;
ret = -1;
{
#if COMPATIBLE
#endif
{
#if COMPATIBLE
#endif
goto disable;
}
{
#if COMPATIBLE
#else
#endif
{
{
goto disable;
}
error(1, "%s: obsolete predefined symbol expanded%s", sym->name, (pp.state & DIRECTIVE) ? "" : " outside of directive");
}
}
(*pp.macref)(sym, error_info.file, error_info.line, (pp.state & CONDITIONAL) ? REF_IF : REF_NORMAL, 0L);
{
n = 2 * MAXTOKEN;
q = p + MAXTOKEN;
while (c = pplex())
{
if (c == '\n')
{
error_info.line++;
}
else if (c == '#')
{
ungetchr(c);
break;
}
else
{
for (;;)
{
{
break;
{
free(p);
ret = 1;
goto disable;
}
}
break;
}
if (!tp)
{
break;
}
}
{
q = p + n - MAXTOKEN;
}
}
else
if (*p)
PUSH_RESCAN(p);
else
free(p);
goto disable;
}
{
/*
* a quick and dirty '(' peek to avoid possibly
* inappropriate ungetchr()'s below
*/
goto disable;
while ((c = pplex()) == '\n')
{
error_info.line++;
}
if (c != '(')
{
if (old_next)
else
{
if (c)
{
ungetchr(*--p);
#if COMPATIBLE
#endif
ungetchr(' ');
}
{
ungetchr('\n');
error_info.line--;
}
}
goto disable;
}
/*
* arg[i][-1] is an extra char for each actual i
* for a possible ungetchr('"') during IN_QUOTE
* arg[i][-1]==0 if arg i need not be expanded
* arg[0][-2] holds the actual arg count
*/
c = 0;
m = 0;
n = 0;
#if MACKEYARGS
{
}
else
#endif
{
*++p = ' ';
}
#if MACKEYARGS
{
switch (pplex())
{
case T_ID:
break;
case ')': /* no actual key args */
c = 0;
goto endactuals;
default:
break;
}
if (pplex() != '=')
if (!c)
p++;
}
#endif
for (;;)
{
switch (pplex())
{
case '(':
n++;
break;
case ')':
if (!n--)
{
p--;
{
if (*q == '\\')
q++;
if (q > p)
*p++ = '\\';
}
#if MACKEYARGS
*p = 0;
m++;
#endif
goto endactuals;
}
break;
case ',':
{
p--;
*p++ = 0;
else
#if MACKEYARGS
{
goto keyarg;
}
#endif
{
c++;
*p++ = ' ';
}
}
break;
case 0:
kp = 0;
else
if (!kp)
{
#if COMPATIBLE
#endif
goto endactuals;
}
continue;
case '\n':
error_info.line++;
/*FALLTHROUGH*/
case ' ':
continue;
}
{
}
{
}
}
{
if (kp)
}
#if MACKEYARGS
#endif
{
c++;
{
else if (c < --n)
#if COMPATIBLE
goto disable;
#endif
}
if (!c)
++c;
}
*p++ = 0;
}
{
}
{
else
ret = 1;
}
}
if (ret < 0 && sym->hidden && !(pp.mode & EXPOSE) && !(pp.state & HEADER) && (pp.in->type == IN_FILE || pp.in->type == IN_MACRO || pp.in->type == IN_EXPAND))
{
ret = 1;
}
return ret;
}