From dbb640b84682eb9b1382fe58c41ba75465bb4a7d Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sat, 18 Jul 2009 18:57:16 -0700 Subject: [PATCH] Drop efunc and evalfunc as input to the preprocessor We only ever invoked the preprocessor with fixed values for efunc and evalfunc, so call nasm_error() and evaluate() directly. Signed-off-by: H. Peter Anvin --- nasm.c | 21 ++++++++------------- nasm.h | 2 +- preproc.c | 13 ++++--------- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/nasm.c b/nasm.c index 5e2e2051..b2ceacce 100644 --- a/nasm.c +++ b/nasm.c @@ -160,7 +160,7 @@ static const struct warning { * not preprocess their source file. */ -static void no_pp_reset(char *, int, efunc, evalfunc, ListGen *, StrList **); +static void no_pp_reset(char *, int, ListGen *, StrList **); static char *no_pp_getline(void); static void no_pp_cleanup(int); static Preproc no_pp = { @@ -367,8 +367,7 @@ int main(int argc, char **argv) if (depend_missing_ok) pp_include_path(NULL); /* "assume generated" */ - preproc->reset(inname, 0, nasm_error, evaluate, &nasmlist, - depend_ptr); + preproc->reset(inname, 0, &nasmlist, depend_ptr); if (outname[0] == '\0') ofmt->filename(inname, outname); ofile = NULL; @@ -397,8 +396,7 @@ int main(int argc, char **argv) location.known = false; /* pass = 1; */ - preproc->reset(inname, 3, nasm_error, evaluate, &nasmlist, - depend_ptr); + preproc->reset(inname, 3, &nasmlist, depend_ptr); while ((line = preproc->getline())) { /* @@ -1196,7 +1194,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) raa_free(offsets); offsets = raa_init(); } - preproc->reset(fname, pass1, nasm_error, evaluate, &nasmlist, + preproc->reset(fname, pass1, &nasmlist, pass1 == 2 ? depend_ptr : NULL); memcpy(warning_on, warning_on_global, (ERR_WARN_MAX+1) * sizeof(bool)); @@ -1969,24 +1967,21 @@ static void usage(void) #define BUF_DELTA 512 static FILE *no_pp_fp; -static efunc no_pp_err; static ListGen *no_pp_list; static int32_t no_pp_lineinc; -static void no_pp_reset(char *file, int pass, efunc error, evalfunc eval, - ListGen * listgen, StrList **deplist) +static void no_pp_reset(char *file, int pass, ListGen * listgen, + StrList **deplist) { src_set_fname(nasm_strdup(file)); src_set_linnum(0); no_pp_lineinc = 1; - no_pp_err = error; no_pp_fp = fopen(file, "r"); if (!no_pp_fp) - no_pp_err(ERR_FATAL | ERR_NOFILE, - "unable to open input file `%s'", file); + nasm_error(ERR_FATAL | ERR_NOFILE, + "unable to open input file `%s'", file); no_pp_list = listgen; (void)pass; /* placate compilers */ - (void)eval; /* placate compilers */ if (deplist) { StrList *sl = nasm_malloc(strlen(file)+1+sizeof sl->next); diff --git a/nasm.h b/nasm.h index a94cb0a2..9e233fce 100644 --- a/nasm.h +++ b/nasm.h @@ -355,7 +355,7 @@ typedef struct preproc_ops { * of the pass, an error reporting function, an evaluator * function, and a listing generator to talk to. */ - void (*reset) (char *, int, efunc, evalfunc, ListGen *, StrList **); + void (*reset) (char *, int, ListGen *, StrList **); /* * Called to fetch a line of preprocessed source. The line diff --git a/preproc.c b/preproc.c index bac5a77a..736bbff9 100644 --- a/preproc.c +++ b/preproc.c @@ -77,6 +77,7 @@ #include "hashtbl.h" #include "quote.h" #include "stdscan.h" +#include "eval.h" #include "tokens.h" #include "tables.h" @@ -380,9 +381,6 @@ static Context *cstk; static Include *istk; static IncPath *ipath = NULL; -static efunc _error; /* Pointer to client-provided error reporting function */ -static evalfunc evaluate; - static int pass; /* HACK: pass 0 = generate dependencies only */ static StrList **dephead, **deptail; /* Dependency list */ @@ -4464,10 +4462,10 @@ static void verror(int severity, const char *fmt, va_list arg) vsnprintf(buff, sizeof(buff), fmt, arg); if (istk && istk->mstk && istk->mstk->name) - _error(severity, "(%s:%d) %s", istk->mstk->name, + nasm_error(severity, "(%s:%d) %s", istk->mstk->name, istk->mstk->lineno, buff); else - _error(severity, "%s", buff); + nasm_error(severity, "%s", buff); } /* @@ -4507,12 +4505,10 @@ static void error_precond(int severity, const char *fmt, ...) } static void -pp_reset(char *file, int apass, efunc errfunc, evalfunc eval, - ListGen * listgen, StrList **deplist) +pp_reset(char *file, int apass, ListGen * listgen, StrList **deplist) { Token *t; - _error = errfunc; cstk = NULL; istk = nasm_malloc(sizeof(Include)); istk->next = NULL; @@ -4540,7 +4536,6 @@ pp_reset(char *file, int apass, efunc errfunc, evalfunc eval, any_extrastdmac = extrastdmac && *extrastdmac; do_predef = true; list = listgen; - evaluate = eval; /* * 0 for dependencies, 1 for preparatory passes, 2 for final pass. -- 2.11.4.GIT