preproc: don't macro-expand the argument to %use
Use expand_id() for the argument to %use, instead of expand_smacro(). This really makes more sense for a "naked" argument. This is a semantic change, but is unlikely to break any real code. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
0b7d903ec8
commit
264b7b982c
3 changed files with 17 additions and 13 deletions
|
@ -14,6 +14,9 @@ since 2007.
|
|||
|
||||
\b \c{%pop} can now take an argument, see \k{pushpop}.
|
||||
|
||||
\b The argument to \c{%use} is no longer macro-expanded. Use
|
||||
\c{%[...]} if macro expansion is desired.
|
||||
|
||||
|
||||
\S{cl-2.05} Version 2.05
|
||||
|
||||
|
|
|
@ -3097,9 +3097,9 @@ package. The standard macro packages are part of NASM, and are
|
|||
described in \k{macropkg}.
|
||||
|
||||
Unlike the \c{%include} directive, package names for the \c{%use}
|
||||
directive do not require quotes, but quotes are permitted; using
|
||||
quotes will prevent unwanted macro expansion. Thus, the following
|
||||
lines are equivalent, unless \c{altreg} is defined as a macro:
|
||||
directive do not require quotes, but quotes are permitted. In NASM
|
||||
2.04 and 2.05 the unquoted form would be macro-expanded; this is no
|
||||
longer true. Thus, the following lines are equivalent:
|
||||
|
||||
\c %use altreg
|
||||
\c %use 'altreg'
|
||||
|
|
21
preproc.c
21
preproc.c
|
@ -2310,24 +2310,25 @@ static int do_directive(Token * tline)
|
|||
static macros_t *use_pkg;
|
||||
const char *pkg_macro;
|
||||
|
||||
t = tline->next = expand_smacro(tline->next);
|
||||
skip_white_(t);
|
||||
tline = tline->next;
|
||||
skip_white_(tline);
|
||||
tline = expand_id(tline);
|
||||
|
||||
if (!t || (t->type != TOK_STRING &&
|
||||
t->type != TOK_INTERNAL_STRING &&
|
||||
t->type != TOK_ID)) {
|
||||
if (!tline || (tline->type != TOK_STRING &&
|
||||
tline->type != TOK_INTERNAL_STRING &&
|
||||
tline->type != TOK_ID)) {
|
||||
error(ERR_NONFATAL, "`%%use' expects a package name");
|
||||
free_tlist(origline);
|
||||
return DIRECTIVE_FOUND; /* but we did _something_ */
|
||||
}
|
||||
if (t->next)
|
||||
if (tline->next)
|
||||
error(ERR_WARNING|ERR_PASS1,
|
||||
"trailing garbage after `%%use' ignored");
|
||||
if (t->type == TOK_STRING)
|
||||
nasm_unquote(t->text, NULL);
|
||||
use_pkg = nasm_stdmac_find_package(t->text);
|
||||
if (tline->type == TOK_STRING)
|
||||
nasm_unquote(tline->text, NULL);
|
||||
use_pkg = nasm_stdmac_find_package(tline->text);
|
||||
if (!use_pkg)
|
||||
error(ERR_NONFATAL, "unknown `%%use' package: %s", t->text);
|
||||
error(ERR_NONFATAL, "unknown `%%use' package: %s", tline->text);
|
||||
/* The first string will be <%define>__USE_*__ */
|
||||
pkg_macro = (char *)use_pkg + 1;
|
||||
if (!smacro_defined(NULL, pkg_macro, 0, NULL, true)) {
|
||||
|
|
Loading…
Reference in a new issue