preproc: Finally drop context-through search

[backport 290eac7569]

2.09 series was the last one we support context-thru search
(and we were issuing a warning about that) so drop all-context
from get_ctx() routine.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2012-03-11 11:38:47 +04:00
parent fd8a7ae7ed
commit 1a42fb28a1

View File

@ -458,8 +458,7 @@ static Blocks blocks = { NULL, NULL };
static Token *expand_mmac_params(Token * tline);
static Token *expand_smacro(Token * tline);
static Token *expand_id(Token * tline);
static Context *get_ctx(const char *name, const char **namep,
bool all_contexts);
static Context *get_ctx(const char *name, const char **namep);
static void make_tok_num(Token * tok, int64_t val);
static void error(int severity, const char *fmt, ...);
static void error_precond(int severity, const char *fmt, ...);
@ -1280,7 +1279,7 @@ static char *detoken(Token * tlist, bool expand_locals)
t->text[0] == '%' && t->text[1] == '$') {
const char *q;
char *p;
Context *ctx = get_ctx(t->text, &q, false);
Context *ctx = get_ctx(t->text, &q);
if (ctx) {
char buffer[40];
snprintf(buffer, sizeof(buffer), "..@%"PRIu32".", ctx->number);
@ -1445,19 +1444,13 @@ static int mmemcmp(const char *p, const char *q, size_t l, bool casesense)
* NULL, having _already_ reported an error condition, if the
* context stack isn't deep enough for the supplied number of $
* signs.
* If all_contexts == true, contexts that enclose current are
* also scanned for such smacro, until it is found; if not -
* only the context that directly results from the number of $'s
* in variable's name.
*
* If "namep" is non-NULL, set it to the pointer to the macro name
* tail, i.e. the part beyond %$...
*/
static Context *get_ctx(const char *name, const char **namep,
bool all_contexts)
static Context *get_ctx(const char *name, const char **namep)
{
Context *ctx;
SMacro *m;
int i;
if (namep)
@ -1488,47 +1481,7 @@ static Context *get_ctx(const char *name, const char **namep,
if (namep)
*namep = name;
if (!all_contexts)
return ctx;
/*
* NOTE: In 2.10 we will not need lookup in extarnal
* contexts, so this is a gentle way to inform users
* about their source code need to be updated
*/
/* first round -- check the current context */
m = hash_findix(&ctx->localmac, name);
while (m) {
if (!mstrcmp(m->name, name, m->casesense))
return ctx;
m = m->next;
}
/* second round - external contexts */
while ((ctx = ctx->next)) {
/* Search for this smacro in found context */
m = hash_findix(&ctx->localmac, name);
while (m) {
if (!mstrcmp(m->name, name, m->casesense)) {
/* NOTE: deprecated as of 2.10 */
static int once = 0;
if (!once) {
error(ERR_WARNING, "context-local macro expansion"
" fall-through (automatic searching of outer"
" contexts) will be deprecated starting in"
" NASM 2.10, please see the NASM Manual for"
" more information");
once = 1;
}
error(ERR_WARNING, "`%s': context-local macro expansion fall-through", name);
return ctx;
}
m = m->next;
}
}
return NULL;
}
/*
@ -1634,7 +1587,7 @@ smacro_defined(Context * ctx, const char *name, int nparam, SMacro ** defn,
smtbl = &ctx->localmac;
} else if (name[0] == '%' && name[1] == '$') {
if (cstk)
ctx = get_ctx(name, &name, false);
ctx = get_ctx(name, &name);
if (!ctx)
return false; /* got to return _something_ */
smtbl = &ctx->localmac;
@ -3042,7 +2995,7 @@ issue_error:
return DIRECTIVE_FOUND;
}
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
last = tline;
param_start = tline = tline->next;
nparam = 0;
@ -3135,7 +3088,7 @@ issue_error:
}
/* Find the context that symbol belongs to */
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
undef_smacro(ctx, mname);
free_tlist(origline);
return DIRECTIVE_FOUND;
@ -3156,7 +3109,7 @@ issue_error:
return DIRECTIVE_FOUND;
}
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
last = tline;
tline = expand_smacro(tline->next);
last->next = NULL;
@ -3197,7 +3150,7 @@ issue_error:
free_tlist(origline);
return DIRECTIVE_FOUND;
}
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
last = tline;
tline = expand_smacro(tline->next);
last->next = NULL;
@ -3252,7 +3205,7 @@ issue_error:
free_tlist(origline);
return DIRECTIVE_FOUND;
}
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
last = tline;
tline = expand_smacro(tline->next);
last->next = NULL;
@ -3313,7 +3266,7 @@ issue_error:
free_tlist(origline);
return DIRECTIVE_FOUND;
}
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
last = tline;
tline = expand_smacro(tline->next);
last->next = NULL;
@ -3359,7 +3312,7 @@ issue_error:
free_tlist(origline);
return DIRECTIVE_FOUND;
}
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
last = tline;
tline = expand_smacro(tline->next);
last->next = NULL;
@ -3424,7 +3377,7 @@ issue_error:
free_tlist(origline);
return DIRECTIVE_FOUND;
}
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
last = tline;
tline = expand_smacro(tline->next);
last->next = NULL;
@ -3526,7 +3479,7 @@ issue_error:
free_tlist(origline);
return DIRECTIVE_FOUND;
}
ctx = get_ctx(tline->text, &mname, false);
ctx = get_ctx(tline->text, &mname);
last = tline;
tline = expand_smacro(tline->next);
last->next = NULL;
@ -4074,7 +4027,7 @@ again:
if (tline->type == TOK_ID) {
head = (SMacro *)hash_findix(&smacros, mname);
} else if (tline->type == TOK_PREPROC_ID) {
ctx = get_ctx(mname, &mname, true);
ctx = get_ctx(mname, &mname);
head = ctx ? (SMacro *)hash_findix(&ctx->localmac, mname) : NULL;
} else
head = NULL;