From 61f130f4e908ba47719571181581e039617220e7 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 25 Sep 2008 15:45:06 -0700 Subject: [PATCH] Set __PASS__ to 3 for preprocess only When running the preprocessor only, set __PASS__ to 3. Signed-off-by: H. Peter Anvin --- doc/nasmdoc.src | 5 ++--- nasm.c | 2 +- preproc.c | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src index 81062daf..5ccb7412 100644 --- a/doc/nasmdoc.src +++ b/doc/nasmdoc.src @@ -3674,9 +3674,8 @@ For example, if the \c{altreg} package is included (see The macro \c{__PASS__} is defined to be \c{1} on preparatory passes, and \c{2} on the final pass. In preprocess-only mode, it is set to -\c{2} (there being only the final pass); when running only to generate -dependencies (due to the \c{-M} or \c{-MG} option, see \k{opt-M}) it -is set to \c{0}. +\c{3}, and when running only to generate dependencies (due to the +\c{-M} or \c{-MG} option, see \k{opt-M}) it is set to \c{0}. \e{Avoid using this macro if at all possible. It is tremendously easy to generate very strange errors by misusing it, and the semantics may diff --git a/nasm.c b/nasm.c index 4d4ab50b..a92db929 100644 --- a/nasm.c +++ b/nasm.c @@ -382,7 +382,7 @@ int main(int argc, char **argv) location.known = false; /* pass = 1; */ - preproc->reset(inname, 2, report_error, evaluate, &nasmlist, + preproc->reset(inname, 3, report_error, evaluate, &nasmlist, depend_ptr); while ((line = preproc->getline())) { diff --git a/preproc.c b/preproc.c index ba895a55..7f1c44f0 100644 --- a/preproc.c +++ b/preproc.c @@ -4249,7 +4249,14 @@ pp_reset(char *file, int apass, efunc errfunc, evalfunc eval, do_predef = true; list = listgen; evaluate = eval; - pass = apass; + + /* + * 0 for dependencies, 1 for preparatory passes, 2 for final pass. + * The caller, however, will also pass in 3 for preprocess-only so + * we can set __PASS__ accordingly. + */ + pass = apass > 2 ? 2 : apass; + dephead = deptail = deplist; if (deplist) { StrList *sl = nasm_malloc(strlen(file)+1+sizeof sl->next); @@ -4259,12 +4266,14 @@ pp_reset(char *file, int apass, efunc errfunc, evalfunc eval, deptail = &sl->next; } - /* Define the __PASS__ macro. This is defined here unlike - all the other builtins, because it is special -- it varies between - passes. */ + /* + * Define the __PASS__ macro. This is defined here unlike + * all the other builtins, because it is special -- it varies between + * passes. + */ t = nasm_malloc(sizeof(*t)); t->next = NULL; - make_tok_num(t, pass); + make_tok_num(t, apass); t->a.mac = NULL; define_smacro(NULL, "__PASS__", true, 0, t); } -- 2.11.4.GIT