diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-09-25 15:45:06 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-09-25 15:45:06 -0700 |
commit | 61f130f4e908ba47719571181581e039617220e7 (patch) | |
tree | c67a0ad5e1de85f2a3a36d80ba5e58d0a1df0d24 | |
parent | 2c8ad285fdd2aa78228fe6ef11e2dacf801b2e04 (diff) | |
download | nasm-61f130f4e908ba47719571181581e039617220e7.tar.gz |
Set __PASS__ to 3 for preprocess only
When running the preprocessor only, set __PASS__ to 3.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | doc/nasmdoc.src | 5 | ||||
-rw-r--r-- | nasm.c | 2 | ||||
-rw-r--r-- | 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 @@ -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())) { @@ -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); } |