diff --git a/asm/preproc.c b/asm/preproc.c index 808303ed..9fc54f8e 100644 --- a/asm/preproc.c +++ b/asm/preproc.c @@ -478,9 +478,8 @@ static size_t nasm_unquote_cstr(char *qstr, enum preproc_token directive) size_t clen = strlen(qstr); if (len != clen) - nasm_error(ERR_NONFATAL, "NUL character in `%s' directive", - pp_directives[directive]); - + nasm_nonfatal("NUL character in `%s' directive", + pp_directives[directive]); return clen; } @@ -909,8 +908,7 @@ static Token *tokenize(char *line) p++; } if (*p != '}') - nasm_error(ERR_WARNING | ERR_PASS1, - "unterminated %%{ construct"); + nasm_warnf(ERR_PASS1, "unterminated %%{ construct"); p[-1] = '\0'; if (*p) p++; @@ -943,8 +941,7 @@ static Token *tokenize(char *line) if (*p) *p++ = '\0'; if (lvl) - nasm_error(ERR_NONFATAL|ERR_PASS1, - "unterminated %%[ construct"); + nasm_nonfatalf(ERR_PASS1, "unterminated %%[ construct"); type = TOK_INDIRECT; } else if (*p == '?') { type = TOK_PREPROC_Q; /* %? */ @@ -966,8 +963,7 @@ static Token *tokenize(char *line) if (*p) p++; else - nasm_error(ERR_NONFATAL|ERR_PASS1, - "unterminated %%! string"); + nasm_nonfatalf(ERR_PASS1, "unterminated %%! string"); } else { /* %! without string or identifier */ type = TOK_OTHER; /* Legacy behavior... */ @@ -1000,7 +996,7 @@ static Token *tokenize(char *line) if (*p) { p++; } else { - nasm_error(ERR_WARNING|ERR_PASS1, "unterminated string"); + nasm_warnf(ERR_PASS1, "unterminated string"); /* Handling unterminated strings by UNV */ /* type = -1; */ } @@ -1248,8 +1244,7 @@ static char *detoken(Token * tlist, bool expand_locals) size_t clen = strlen(v); if (len != clen) { - nasm_error(ERR_NONFATAL | ERR_PASS1, - "NUL character in %%! string"); + nasm_nonfatalf(ERR_PASS1, "NUL character in %%! string"); v = NULL; } } @@ -1257,8 +1252,7 @@ static char *detoken(Token * tlist, bool expand_locals) if (v) { char *p = getenv(v); if (!p) { - nasm_error(ERR_NONFATAL | ERR_PASS1, - "nonexistent environment variable `%s'", v); + nasm_nonfatalf(ERR_PASS1, "nonexistent environment variable `%s'", v); /* * FIXME We better should investigate if accessing * ->text[1] without ->text[0] is safe enough. @@ -1457,7 +1451,7 @@ static Context *get_ctx(const char *name, const char **namep) return NULL; if (!cstk) { - nasm_error(ERR_NONFATAL, "`%s': context stack is empty", name); + nasm_nonfatal("`%s': context stack is empty", name); return NULL; } @@ -1470,8 +1464,8 @@ static Context *get_ctx(const char *name, const char **namep) ctx = ctx->next; } if (!ctx) { - nasm_error(ERR_NONFATAL, "`%s': context stack is only" - " %d level%s deep", name, i, (i == 1 ? "" : "s")); + nasm_nonfatal("`%s': context stack is only" + " %d level%s deep", name, i, (i == 1 ? "" : "s")); return NULL; } @@ -1662,11 +1656,10 @@ static int read_param_count(const char *str) result = readnum(str, &err); if (result < 0 || result > INT_MAX) { result = 0; - nasm_error(ERR_NONFATAL, "parameter count `%s' is out of bounds [%d; %d]", - str, 0, INT_MAX); - } else if (err) { - nasm_error(ERR_NONFATAL, "unable to parse parameter count `%s'", str); - } + nasm_nonfatal("parameter count `%s' is out of bounds [%d; %d]", + str, 0, INT_MAX); + } else if (err) + nasm_nonfatal("unable to parse parameter count `%s'", str); return result; } @@ -1709,8 +1702,7 @@ static void count_mmac_params(Token * t, int *nparam, Token *** params) t = t->next; skip_white_(t); if (tok_isnt_(t, ",")) { - nasm_error(ERR_NONFATAL, - "braces do not enclose all of macro parameter"); + nasm_nonfatal("braces do not enclose all of macro parameter"); while (tok_isnt_(t, ",")) t = t->next; } @@ -1751,8 +1743,8 @@ static bool if_condition(Token * tline, enum preproc_token ct) if (!tline) break; if (tline->type != TOK_ID) { - nasm_error(ERR_NONFATAL, - "`%s' expects context identifiers", pp_directives[ct]); + nasm_nonfatal("`%s' expects context identifiers", + pp_directives[ct]); free_tlist(origline); return -1; } @@ -1769,8 +1761,8 @@ static bool if_condition(Token * tline, enum preproc_token ct) if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, - "`%s' expects macro identifiers", pp_directives[ct]); + nasm_nonfatal("`%s' expects macro identifiers", + pp_directives[ct]); goto fail; } if (smacro_defined(NULL, tline->text, 0, NULL, true)) @@ -1788,9 +1780,8 @@ static bool if_condition(Token * tline, enum preproc_token ct) tline->type != TOK_STRING && (tline->type != TOK_PREPROC_ID || tline->text[1] != '!'))) { - nasm_error(ERR_NONFATAL, - "`%s' expects environment variable names", - pp_directives[ct]); + nasm_nonfatal("`%s' expects environment variable names", + pp_directives[ct]); goto fail; } p = tline->text; @@ -1811,17 +1802,16 @@ static bool if_condition(Token * tline, enum preproc_token ct) while (tok_isnt_(tt, ",")) tt = tt->next; if (!tt) { - nasm_error(ERR_NONFATAL, - "`%s' expects two comma-separated arguments", - pp_directives[ct]); + nasm_nonfatal("`%s' expects two comma-separated arguments", + pp_directives[ct]); goto fail; } tt = tt->next; j = true; /* assume equality unless proved not */ while ((t->type != TOK_OTHER || strcmp(t->text, ",")) && tt) { if (tt->type == TOK_OTHER && !strcmp(tt->text, ",")) { - nasm_error(ERR_NONFATAL, "`%s': more than one comma on line", - pp_directives[ct]); + nasm_nonfatal("`%s': more than one comma on line", + pp_directives[ct]); goto fail; } if (t->type == TOK_WHITESPACE) { @@ -1869,8 +1859,7 @@ static bool if_condition(Token * tline, enum preproc_token ct) skip_white_(tline); tline = expand_id(tline); if (!tok_type_(tline, TOK_ID)) { - nasm_error(ERR_NONFATAL, - "`%s' expects a macro name", pp_directives[ct]); + nasm_nonfatal("`%s' expects a macro name", pp_directives[ct]); goto fail; } searching.name = nasm_strdup(tline->text); @@ -1886,9 +1875,8 @@ static bool if_condition(Token * tline, enum preproc_token ct) skip_white_(tline); if (!tline) { } else if (!tok_type_(tline, TOK_NUMBER)) { - nasm_error(ERR_NONFATAL, - "`%s' expects a parameter count or nothing", - pp_directives[ct]); + nasm_nonfatal("`%s' expects a parameter count or nothing", + pp_directives[ct]); } else { searching.nparam_min = searching.nparam_max = read_param_count(tline->text); @@ -1898,14 +1886,12 @@ static bool if_condition(Token * tline, enum preproc_token ct) if (tok_is_(tline, "*")) searching.nparam_max = INT_MAX; else if (!tok_type_(tline, TOK_NUMBER)) - nasm_error(ERR_NONFATAL, - "`%s' expects a parameter count after `-'", - pp_directives[ct]); + nasm_nonfatal("`%s' expects a parameter count after `-'", + pp_directives[ct]); else { searching.nparam_max = read_param_count(tline->text); if (searching.nparam_min > searching.nparam_max) { - nasm_error(ERR_NONFATAL, - "minimum parameter count exceeds maximum"); + nasm_nonfatal("minimum parameter count exceeds maximum"); searching.nparam_max = searching.nparam_min; } } @@ -1927,8 +1913,7 @@ static bool if_condition(Token * tline, enum preproc_token ct) mmac = mmac->next; } if (tline && tline->next) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after %%ifmacro ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after %%ifmacro ignored"); nasm_free(searching.name); j = found; break; @@ -1988,20 +1973,18 @@ iftype: if (!evalresult) return -1; if (tokval.t_type) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after expression ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after expression ignored"); if (!is_simple(evalresult)) { - nasm_error(ERR_NONFATAL, - "non-constant value given to `%s'", pp_directives[ct]); + nasm_nonfatal("non-constant value given to `%s'", + pp_directives[ct]); goto fail; } j = reloc_value(evalresult) != 0; break; default: - nasm_error(ERR_FATAL, - "preprocessor directive `%s' not yet implemented", - pp_directives[ct]); + nasm_fatal("preprocessor directive `%s' not yet implemented", + pp_directives[ct]); goto fail; } @@ -2024,9 +2007,8 @@ static bool define_smacro(Context *ctx, const char *mname, bool casesense, if (smacro_defined(ctx, mname, nparam, &smac, casesense)) { if (!smac) { - nasm_error(ERR_WARNING|ERR_PASS1, - "single-line macro `%s' defined both with and" - " without parameters", mname); + nasm_warnf(ERR_PASS1, "single-line macro `%s' defined both with and" + " without parameters", mname); /* * Some instances of the old code considered this a failure, * some others didn't. What is the right thing to do here? @@ -2095,7 +2077,7 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive) skip_white_(tline); tline = expand_id(tline); if (!tok_type_(tline, TOK_ID)) { - nasm_error(ERR_NONFATAL, "`%s' expects a macro name", directive); + nasm_nonfatal("`%s' expects a macro name", directive); return false; } @@ -2110,22 +2092,20 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive) tline = expand_smacro(tline->next); skip_white_(tline); - if (!tok_type_(tline, TOK_NUMBER)) { - nasm_error(ERR_NONFATAL, "`%s' expects a parameter count", directive); - } else { + if (!tok_type_(tline, TOK_NUMBER)) + nasm_nonfatal("`%s' expects a parameter count", directive); + else def->nparam_min = def->nparam_max = read_param_count(tline->text); - } if (tline && tok_is_(tline->next, "-")) { tline = tline->next->next; if (tok_is_(tline, "*")) { def->nparam_max = INT_MAX; } else if (!tok_type_(tline, TOK_NUMBER)) { - nasm_error(ERR_NONFATAL, - "`%s' expects a parameter count after `-'", directive); + nasm_nonfatal("`%s' expects a parameter count after `-'", directive); } else { def->nparam_max = read_param_count(tline->text); if (def->nparam_min > def->nparam_max) { - nasm_error(ERR_NONFATAL, "minimum parameter count exceeds maximum"); + nasm_nonfatal("minimum parameter count exceeds maximum"); def->nparam_max = def->nparam_min; } } @@ -2155,8 +2135,7 @@ static bool parse_mmacro_spec(Token *tline, MMacro *def, const char *directive) if (def->defaults && def->ndefs > def->nparam_max - def->nparam_min && !def->plus) - nasm_error(ERR_WARNING|ERR_PASS1|ERR_WARN_MDP, - "too many default macro parameters"); + nasm_warnf(ERR_PASS1|ERR_WARN_MDP, "too many default macro parameters"); return true; } @@ -2246,9 +2225,8 @@ static int do_directive(Token *tline, char **output) * in future release (2.09-2.10) */ if (i == PP_RMACRO || i == PP_IRMACRO || i == PP_EXITMACRO) { - nasm_error(ERR_NONFATAL, "unknown preprocessor directive `%s'", - tline->text); - return NO_DIRECTIVE_FOUND; + nasm_nonfatal("unknown preprocessor directive `%s'", tline->text); + return NO_DIRECTIVE_FOUND; } /* @@ -2301,8 +2279,7 @@ static int do_directive(Token *tline, char **output) switch (i) { case PP_INVALID: - nasm_error(ERR_NONFATAL, "unknown preprocessor directive `%s'", - tline->text); + nasm_nonfatal("unknown preprocessor directive `%s'", tline->text); return NO_DIRECTIVE_FOUND; /* didn't get it */ case PP_PRAGMA: @@ -2347,7 +2324,7 @@ static int do_directive(Token *tline, char **output) if (tline && tline->type == TOK_WHITESPACE) tline = tline->next; if (!tline || tline->type != TOK_ID) { - nasm_error(ERR_NONFATAL, "`%%stacksize' missing size parameter"); + nasm_nonfatal("`%%stacksize' missing size parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -2380,7 +2357,7 @@ static int do_directive(Token *tline, char **output) ArgOffset = 6; LocalOffset = 0; } else { - nasm_error(ERR_NONFATAL, "`%%stacksize' invalid size type"); + nasm_nonfatal("`%%stacksize' invalid size type"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -2403,7 +2380,7 @@ static int do_directive(Token *tline, char **output) if (tline && tline->type == TOK_WHITESPACE) tline = tline->next; if (!tline || tline->type != TOK_ID) { - nasm_error(ERR_NONFATAL, "`%%arg' missing argument parameter"); + nasm_nonfatal("`%%arg' missing argument parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -2413,14 +2390,13 @@ static int do_directive(Token *tline, char **output) tline = tline->next; if (!tline || tline->type != TOK_OTHER || tline->text[0] != ':') { - nasm_error(ERR_NONFATAL, - "Syntax error processing `%%arg' directive"); + nasm_nonfatal("Syntax error processing `%%arg' directive"); free_tlist(origline); return DIRECTIVE_FOUND; } tline = tline->next; if (!tline || tline->type != TOK_ID) { - nasm_error(ERR_NONFATAL, "`%%arg' missing size type parameter"); + nasm_nonfatal("`%%arg' missing size type parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -2430,8 +2406,7 @@ static int do_directive(Token *tline, char **output) tt = expand_smacro(tt); size = parse_size(tt->text); if (!size) { - nasm_error(ERR_NONFATAL, - "Invalid size type for `%%arg' missing directive"); + nasm_nonfatal("Invalid size type for `%%arg' missing directive"); free_tlist(tt); free_tlist(origline); return DIRECTIVE_FOUND; @@ -2476,8 +2451,7 @@ static int do_directive(Token *tline, char **output) if (tline && tline->type == TOK_WHITESPACE) tline = tline->next; if (!tline || tline->type != TOK_ID) { - nasm_error(ERR_NONFATAL, - "`%%local' missing argument parameter"); + nasm_nonfatal("`%%local' missing argument parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -2487,15 +2461,13 @@ static int do_directive(Token *tline, char **output) tline = tline->next; if (!tline || tline->type != TOK_OTHER || tline->text[0] != ':') { - nasm_error(ERR_NONFATAL, - "Syntax error processing `%%local' directive"); + nasm_nonfatal("Syntax error processing `%%local' directive"); free_tlist(origline); return DIRECTIVE_FOUND; } tline = tline->next; if (!tline || tline->type != TOK_ID) { - nasm_error(ERR_NONFATAL, - "`%%local' missing size type parameter"); + nasm_nonfatal("`%%local' missing size type parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -2505,8 +2477,7 @@ static int do_directive(Token *tline, char **output) tt = expand_smacro(tt); size = parse_size(tt->text); if (!size) { - nasm_error(ERR_NONFATAL, - "Invalid size type for `%%local' missing directive"); + nasm_nonfatal("Invalid size type for `%%local' missing directive"); free_tlist(tt); free_tlist(origline); return DIRECTIVE_FOUND; @@ -2539,8 +2510,7 @@ static int do_directive(Token *tline, char **output) case PP_CLEAR: if (tline->next) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after `%%clear' ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after `%%clear' ignored"); free_macros(); init_macros(); free_tlist(origline); @@ -2551,13 +2521,12 @@ static int do_directive(Token *tline, char **output) skip_white_(t); if (!t || (t->type != TOK_STRING && t->type != TOK_INTERNAL_STRING)) { - nasm_error(ERR_NONFATAL, "`%%depend' expects a file name"); + nasm_nonfatal("`%%depend' expects a file name"); free_tlist(origline); return DIRECTIVE_FOUND; /* but we did _something_ */ } if (t->next) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after `%%depend' ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after `%%depend' ignored"); p = t->text; if (t->type != TOK_INTERNAL_STRING) nasm_unquote_cstr(p, i); @@ -2571,13 +2540,12 @@ static int do_directive(Token *tline, char **output) if (!t || (t->type != TOK_STRING && t->type != TOK_INTERNAL_STRING)) { - nasm_error(ERR_NONFATAL, "`%%include' expects a file name"); + nasm_nonfatal("`%%include' expects a file name"); free_tlist(origline); return DIRECTIVE_FOUND; /* but we did _something_ */ } if (t->next) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after `%%include' ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after `%%include' ignored"); p = t->text; if (t->type != TOK_INTERNAL_STRING) nasm_unquote_cstr(p, i); @@ -2614,18 +2582,17 @@ static int do_directive(Token *tline, char **output) if (!tline || (tline->type != TOK_STRING && tline->type != TOK_INTERNAL_STRING && tline->type != TOK_ID)) { - nasm_error(ERR_NONFATAL, "`%%use' expects a package name"); + nasm_nonfatal("`%%use' expects a package name"); free_tlist(origline); return DIRECTIVE_FOUND; /* but we did _something_ */ } if (tline->next) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after `%%use' ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after `%%use' ignored"); if (tline->type == TOK_STRING) nasm_unquote_cstr(tline->text, i); use_pkg = nasm_stdmac_find_package(tline->text); if (!use_pkg) - nasm_error(ERR_NONFATAL, "unknown `%%use' package: %s", tline->text); + nasm_nonfatal("unknown `%%use' package: %s", tline->text); else pkg_macro = (char *)use_pkg + 1; /* The first string will be <%define>__USE_*__ */ if (use_pkg && ! smacro_defined(NULL, pkg_macro, 0, NULL, true)) { @@ -2643,15 +2610,14 @@ static int do_directive(Token *tline, char **output) tline = expand_id(tline); if (tline) { if (!tok_type_(tline, TOK_ID)) { - nasm_error(ERR_NONFATAL, "`%s' expects a context identifier", - pp_directives[i]); + nasm_nonfatal("`%s' expects a context identifier", + pp_directives[i]); free_tlist(origline); return DIRECTIVE_FOUND; /* but we did _something_ */ } if (tline->next) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after `%s' ignored", - pp_directives[i]); + nasm_warnf(ERR_PASS1, "trailing garbage after `%s' ignored", + pp_directives[i]); p = nasm_strdup(tline->text); } else { p = NULL; /* Anonymous */ @@ -2667,13 +2633,12 @@ static int do_directive(Token *tline, char **output) } else { /* %pop or %repl */ if (!cstk) { - nasm_error(ERR_NONFATAL, "`%s': context stack is empty", - pp_directives[i]); + nasm_nonfatal("`%s': context stack is empty", + pp_directives[i]); } else if (i == PP_POP) { if (p && (!cstk->name || nasm_stricmp(p, cstk->name))) - nasm_error(ERR_NONFATAL, "`%%pop' in wrong context: %s, " - "expected %s", - cstk->name ? cstk->name : "anonymous", p); + nasm_nonfatal("`%%pop' in wrong context: %s, expected %s", + cstk->name ? cstk->name : "anonymous", p); else ctx_pop(); } else { @@ -2741,7 +2706,7 @@ issue_error: CASE_PP_ELIF: if (!istk->conds) - nasm_error(ERR_FATAL, "`%s': no matching `%%if'", pp_directives[i]); + nasm_fatal("`%s': no matching `%%if'", pp_directives[i]); switch(istk->conds->state) { case COND_IF_TRUE: istk->conds->state = COND_DONE; @@ -2753,8 +2718,8 @@ issue_error: case COND_ELSE_TRUE: case COND_ELSE_FALSE: - nasm_error(ERR_WARNING|ERR_PASS1|ERR_PP_PRECOND, - "`%%elif' after `%%else' ignored"); + nasm_warnf(ERR_PASS1|ERR_PP_PRECOND, + "`%%elif' after `%%else' ignored"); istk->conds->state = COND_NEVER; break; @@ -2778,8 +2743,8 @@ issue_error: case PP_ELSE: if (tline->next) - nasm_error(ERR_WARNING|ERR_PASS1|ERR_PP_PRECOND, - "trailing garbage after `%%else' ignored"); + nasm_warnf(ERR_PASS1|ERR_PP_PRECOND, + "trailing garbage after `%%else' ignored"); if (!istk->conds) nasm_fatal("`%%else: no matching `%%if'"); switch(istk->conds->state) { @@ -2797,8 +2762,8 @@ issue_error: case COND_ELSE_TRUE: case COND_ELSE_FALSE: - nasm_error(ERR_WARNING|ERR_PASS1|ERR_PP_PRECOND, - "`%%else' after `%%else' ignored."); + nasm_warnf(ERR_PASS1|ERR_PP_PRECOND, + "`%%else' after `%%else' ignored."); istk->conds->state = COND_NEVER; break; } @@ -2807,10 +2772,10 @@ issue_error: case PP_ENDIF: if (tline->next) - nasm_error(ERR_WARNING|ERR_PASS1|ERR_PP_PRECOND, - "trailing garbage after `%%endif' ignored"); + nasm_warnf(ERR_PASS1|ERR_PP_PRECOND, + "trailing garbage after `%%endif' ignored"); if (!istk->conds) - nasm_error(ERR_FATAL, "`%%endif': no matching `%%if'"); + nasm_fatal("`%%endif': no matching `%%if'"); cond = istk->conds; istk->conds = cond->next; nasm_free(cond); @@ -2824,8 +2789,8 @@ issue_error: case PP_MACRO: case PP_IMACRO: if (defining) { - nasm_error(ERR_FATAL, "`%s': already defining a macro", - pp_directives[i]); + nasm_fatal("`%s': already defining a macro", + pp_directives[i]); return DIRECTIVE_FOUND; } defining = nasm_zalloc(sizeof(MMacro)); @@ -2847,8 +2812,8 @@ issue_error: || defining->plus) && (defining->nparam_min <= mmac->nparam_max || mmac->plus)) { - nasm_error(ERR_WARNING|ERR_PASS1, - "redefining multi-line macro `%s'", defining->name); + nasm_warnf(ERR_PASS1, "redefining multi-line macro `%s'", + defining->name); return DIRECTIVE_FOUND; } mmac = mmac->next; @@ -2859,7 +2824,7 @@ issue_error: case PP_ENDM: case PP_ENDMACRO: if (! (defining && defining->name)) { - nasm_error(ERR_NONFATAL, "`%s': not defining a macro", tline->text); + nasm_nonfatal("`%s': not defining a macro", tline->text); return DIRECTIVE_FOUND; } mmhead = (MMacro **) hash_findi_add(&mmacros, defining->name); @@ -2891,7 +2856,7 @@ issue_error: } istk->expansion = l; } else { - nasm_error(ERR_NONFATAL, "`%%exitmacro' not within `%%macro' block"); + nasm_nonfatal("`%%exitmacro' not within `%%macro' block"); } free_tlist(origline); return DIRECTIVE_FOUND; @@ -2930,7 +2895,7 @@ issue_error: tline = tline->next; if (!tline->next) { free_tlist(origline); - nasm_error(ERR_NONFATAL, "`%%rotate' missing rotate count"); + nasm_nonfatal("`%%rotate' missing rotate count"); return DIRECTIVE_FOUND; } t = expand_smacro(tline->next); @@ -2945,20 +2910,18 @@ issue_error: if (!evalresult) return DIRECTIVE_FOUND; if (tokval.t_type) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after expression ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after expression ignored"); if (!is_simple(evalresult)) { - nasm_error(ERR_NONFATAL, "non-constant value given to `%%rotate'"); + nasm_nonfatal("non-constant value given to `%%rotate'"); return DIRECTIVE_FOUND; } mmac = istk->mstk; while (mmac && !mmac->name) /* avoid mistaking %reps for macros */ mmac = mmac->next_active; if (!mmac) { - nasm_error(ERR_NONFATAL, "`%%rotate' invoked outside a macro call"); + nasm_nonfatal("`%%rotate' invoked outside a macro call"); } else if (mmac->nparam == 0) { - nasm_error(ERR_NONFATAL, - "`%%rotate' invoked within macro without parameters"); + nasm_nonfatal("`%%rotate' invoked within macro without parameters"); } else { int rotate = mmac->rotate + reloc_value(evalresult); @@ -2995,27 +2958,25 @@ issue_error: return DIRECTIVE_FOUND; } if (tokval.t_type) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after expression ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after expression ignored"); if (!is_simple(evalresult)) { - nasm_error(ERR_NONFATAL, "non-constant value given to `%%rep'"); + nasm_nonfatal("non-constant value given to `%%rep'"); return DIRECTIVE_FOUND; } count = reloc_value(evalresult); if (count > nasm_limit[LIMIT_REP]) { - nasm_error(ERR_NONFATAL, - "`%%rep' count %"PRId64" exceeds limit (currently %"PRId64")", - count, nasm_limit[LIMIT_REP]); + nasm_nonfatal("`%%rep' count %"PRId64" exceeds limit (currently %"PRId64")", + count, nasm_limit[LIMIT_REP]); count = 0; } else if (count < 0) { - nasm_error(ERR_WARNING|ERR_PASS2|ERR_WARN_NEG_REP, + nasm_warnf(ERR_PASS2|ERR_WARN_NEG_REP, "negative `%%rep' count: %"PRId64, count); count = 0; } else { count++; } } else { - nasm_error(ERR_NONFATAL, "`%%rep' expects a repeat count"); + nasm_nonfatal("`%%rep' expects a repeat count"); count = 0; } free_tlist(origline); @@ -3039,7 +3000,7 @@ issue_error: case PP_ENDREP: if (!defining || defining->name) { - nasm_error(ERR_NONFATAL, "`%%endrep': no matching `%%rep'"); + nasm_nonfatal("`%%endrep': no matching `%%rep'"); return DIRECTIVE_FOUND; } @@ -3081,7 +3042,7 @@ issue_error: if (l) l->finishes->in_progress = 1; else - nasm_error(ERR_NONFATAL, "`%%exitrep' not within `%%rep' block"); + nasm_nonfatal("`%%exitrep' not within `%%rep' block"); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3097,7 +3058,7 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, "`%s' expects a macro identifier", + nasm_nonfatal("`%s' expects a macro identifier", pp_directives[i]); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3121,14 +3082,13 @@ issue_error: while (1) { skip_white_(tline); if (!tline) { - nasm_error(ERR_NONFATAL, "parameter identifier expected"); + nasm_nonfatal("parameter identifier expected"); free_tlist(origline); return DIRECTIVE_FOUND; } if (tline->type != TOK_ID) { - nasm_error(ERR_NONFATAL, - "`%s': parameter identifier expected", - tline->text); + nasm_nonfatal("`%s': parameter identifier expected", + tline->text); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3139,8 +3099,7 @@ issue_error: tline = tline->next; } else { if (!tok_is_(tline, ")")) { - nasm_error(ERR_NONFATAL, - "`)' expected to terminate macro template"); + nasm_nonfatal("`)' expected to terminate macro template"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3186,14 +3145,12 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, "`%%undef' expects a macro identifier"); + nasm_nonfatal("`%%undef' expects a macro identifier"); free_tlist(origline); return DIRECTIVE_FOUND; } - if (tline->next) { - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after macro name ignored"); - } + if (tline->next) + nasm_warnf(ERR_PASS1, "trailing garbage after macro name ignored"); /* Find the context that symbol belongs to */ ctx = get_ctx(tline->text, &mname); @@ -3211,7 +3168,7 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, "`%s' expects a macro identifier", + nasm_nonfatal("`%s' expects a macro identifier", pp_directives[i]); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3252,9 +3209,8 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, - "`%s' expects a macro identifier as first parameter", - pp_directives[i]); + nasm_nonfatal("`%s' expects a macro identifier as first parameter", + pp_directives[i]); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3268,9 +3224,8 @@ issue_error: t = t->next; /* t should now point to the string */ if (!tok_type_(t, TOK_STRING)) { - nasm_error(ERR_NONFATAL, - "`%s` requires string as second parameter", - pp_directives[i]); + nasm_nonfatal("`%s` requires string as second parameter", + pp_directives[i]); free_tlist(tline); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3306,8 +3261,7 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, - "`%%pathsearch' expects a macro identifier as first parameter"); + nasm_nonfatal("`%%pathsearch' expects a macro identifier as first parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3322,14 +3276,13 @@ issue_error: if (!t || (t->type != TOK_STRING && t->type != TOK_INTERNAL_STRING)) { - nasm_error(ERR_NONFATAL, "`%%pathsearch' expects a file name"); + nasm_nonfatal("`%%pathsearch' expects a file name"); free_tlist(tline); free_tlist(origline); return DIRECTIVE_FOUND; /* but we did _something_ */ } if (t->next) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after `%%pathsearch' ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after `%%pathsearch' ignored"); p = t->text; if (t->type != TOK_INTERNAL_STRING) nasm_unquote(p, NULL); @@ -3363,8 +3316,7 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, - "`%%strlen' expects a macro identifier as first parameter"); + nasm_nonfatal("`%%strlen' expects a macro identifier as first parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3378,8 +3330,7 @@ issue_error: t = t->next; /* t should now point to the string */ if (!tok_type_(t, TOK_STRING)) { - nasm_error(ERR_NONFATAL, - "`%%strlen` requires string as second parameter"); + nasm_nonfatal("`%%strlen` requires string as second parameter"); free_tlist(tline); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3409,8 +3360,7 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, - "`%%strcat' expects a macro identifier as first parameter"); + nasm_nonfatal("`%%strcat' expects a macro identifier as first parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3432,8 +3382,7 @@ issue_error: break; /* else fall through */ default: - nasm_error(ERR_NONFATAL, - "non-string passed to `%%strcat' (%d)", t->type); + nasm_nonfatal("non-string passed to `%%strcat' (%d)", t->type); free_tlist(tline); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3474,8 +3423,7 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, - "`%%substr' expects a macro identifier as first parameter"); + nasm_nonfatal("`%%substr' expects a macro identifier as first parameter"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3491,8 +3439,7 @@ issue_error: /* t should now point to the string */ if (!tok_type_(t, TOK_STRING)) { - nasm_error(ERR_NONFATAL, - "`%%substr` requires string as second parameter"); + nasm_nonfatal("`%%substr` requires string as second parameter"); free_tlist(tline); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3507,7 +3454,7 @@ issue_error: free_tlist(origline); return DIRECTIVE_FOUND; } else if (!is_simple(evalresult)) { - nasm_error(ERR_NONFATAL, "non-constant value given to `%%substr`"); + nasm_nonfatal("non-constant value given to `%%substr`"); free_tlist(tline); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3526,7 +3473,7 @@ issue_error: free_tlist(origline); return DIRECTIVE_FOUND; } else if (!is_simple(evalresult)) { - nasm_error(ERR_NONFATAL, "non-constant value given to `%%substr`"); + nasm_nonfatal("non-constant value given to `%%substr`"); free_tlist(tline); free_tlist(origline); return DIRECTIVE_FOUND; @@ -3573,9 +3520,8 @@ issue_error: if (!tline || (tline->type != TOK_ID && (tline->type != TOK_PREPROC_ID || tline->text[1] != '$'))) { - nasm_error(ERR_NONFATAL, - "`%%%sassign' expects a macro identifier", - (i == PP_IASSIGN ? "i" : "")); + nasm_nonfatal("`%%%sassign' expects a macro identifier", + (i == PP_IASSIGN ? "i" : "")); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3595,13 +3541,11 @@ issue_error: } if (tokval.t_type) - nasm_error(ERR_WARNING|ERR_PASS1, - "trailing garbage after expression ignored"); + nasm_warnf(ERR_PASS1, "trailing garbage after expression ignored"); if (!is_simple(evalresult)) { - nasm_error(ERR_NONFATAL, - "non-constant value given to `%%%sassign'", - (i == PP_IASSIGN ? "i" : "")); + nasm_nonfatal("non-constant value given to `%%%sassign'", + (i == PP_IASSIGN ? "i" : "")); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3627,7 +3571,7 @@ issue_error: tline = tline->next; skip_white_(tline); if (!tok_type_(tline, TOK_NUMBER)) { - nasm_error(ERR_NONFATAL, "`%%line' expects line number"); + nasm_nonfatal("`%%line' expects line number"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3637,7 +3581,7 @@ issue_error: if (tok_is_(tline, "+")) { tline = tline->next; if (!tok_type_(tline, TOK_NUMBER)) { - nasm_error(ERR_NONFATAL, "`%%line' expects line increment"); + nasm_nonfatal("`%%line' expects line increment"); free_tlist(origline); return DIRECTIVE_FOUND; } @@ -3656,9 +3600,8 @@ issue_error: return DIRECTIVE_FOUND; default: - nasm_error(ERR_FATAL, - "preprocessor directive `%s' not yet implemented", - pp_directives[i]); + nasm_fatal("preprocessor directive `%s' not yet implemented", + pp_directives[i]); return DIRECTIVE_FOUND; } } @@ -3745,7 +3688,7 @@ static bool paste_tokens(Token **head, const struct tokseq_match *m, /* Left pasting token is start of line */ if (!prev_nonspace) - nasm_error(ERR_FATAL, "No lvalue found on pasting"); + nasm_fatal("No lvalue found on pasting"); /* * No ending token, this might happen in two @@ -3945,7 +3888,7 @@ static Token *expand_mmac_params_range(MMacro *mac, Token *tline, Token ***last) return head; err: - nasm_error(ERR_NONFATAL, "`%%{%s}': macro parameters out of range", + nasm_nonfatal("`%%{%s}': macro parameters out of range", &tline->text[1]); return tline; } @@ -3983,7 +3926,7 @@ static Token *expand_mmac_params(Token * tline) while (mac && !mac->name) /* avoid mistaking %reps for macros */ mac = mac->next_active; if (!mac) { - nasm_error(ERR_NONFATAL, "`%s': not in a macro call", t->text); + nasm_nonfatal("`%s': not in a macro call", t->text); } else { pos = strchr(t->text, ':'); if (!pos) { @@ -4014,16 +3957,14 @@ static Token *expand_mmac_params(Token * tline) } cc = find_cc(tt); if (cc == -1) { - nasm_error(ERR_NONFATAL, - "macro parameter %d is not a condition code", - n + 1); + nasm_nonfatal("macro parameter %d is not a condition code", + n + 1); text = NULL; } else { type = TOK_ID; if (inverse_ccs[cc] == -1) { - nasm_error(ERR_NONFATAL, - "condition code `%s' is not invertible", - conditions[cc]); + nasm_nonfatal("condition code `%s' is not invertible", + conditions[cc]); text = NULL; } else text = nasm_strdup(conditions[inverse_ccs[cc]]); @@ -4040,9 +3981,8 @@ static Token *expand_mmac_params(Token * tline) } cc = find_cc(tt); if (cc == -1) { - nasm_error(ERR_NONFATAL, - "macro parameter %d is not a condition code", - n + 1); + nasm_nonfatal("macro parameter %d is not a condition code", + n + 1); text = NULL; } else { type = TOK_ID; @@ -4182,7 +4122,7 @@ again: while (tline) { /* main token loop */ if (!--deadman) { - nasm_error(ERR_NONFATAL, "interminable macro recursion"); + nasm_nonfatal("interminable macro recursion"); goto err; } @@ -4287,8 +4227,7 @@ again: tline = t; if (!tline) { - nasm_error(ERR_NONFATAL, - "macro call expects terminating `)'"); + nasm_nonfatal("macro call expects terminating `)'"); break; } if (tline->type == TOK_WHITESPACE @@ -4337,7 +4276,7 @@ again: } if (brackets < 0) { brackets = 0; - nasm_error(ERR_NONFATAL, "braces do not " + nasm_nonfatal("braces do not " "enclose all of macro parameter"); } paramsize[nparam] += white + 1; @@ -4349,10 +4288,10 @@ again: m->casesense))) m = m->next; if (!m) - nasm_error(ERR_WARNING|ERR_PASS1|ERR_WARN_MNP, - "macro `%s' exists, " - "but not taking %d parameters", - mstart->text, nparam); + nasm_warnf(ERR_PASS1|ERR_WARN_MNP, + "macro `%s' exists, " + "but not taking %d parameters", + mstart->text, nparam); } } if (m && m->in_progress) @@ -4401,8 +4340,7 @@ again: * FIXME: Need to handle more gracefully, * exiting early on agruments analysis. */ - nasm_error(ERR_FATAL, - "macro `%s' expects %d args", + nasm_fatal("macro `%s' expects %d args", mstart->text, (int)paramsize[t->type - TOK_SMAC_PARAM]); } @@ -4599,9 +4537,8 @@ static MMacro *is_mmacro(Token * tline, Token *** params_array) */ if (m->in_progress > m->max_depth) { if (m->max_depth > 0) { - nasm_error(ERR_WARNING, - "reached maximum recursion depth of %i", - m->max_depth); + nasm_warn("reached maximum recursion depth of %i", + m->max_depth); } nasm_free(params); return NULL; @@ -4651,9 +4588,9 @@ static MMacro *is_mmacro(Token * tline, Token *** params_array) * After all that, we didn't find one with the right number of * parameters. Issue a warning, and fail to expand the macro. */ - nasm_error(ERR_WARNING|ERR_PASS1|ERR_WARN_MNP, - "macro `%s' exists, but not taking %d parameters", - tline->text, nparam); + nasm_warnf(ERR_PASS1|ERR_WARN_MNP, + "macro `%s' exists, but not taking %d parameters", + tline->text, nparam); nasm_free(params); return NULL; } @@ -4787,7 +4724,7 @@ static int expand_mmacro(Token * tline) paramlen[i]++; } if (brace) - nasm_error(ERR_NONFATAL, "macro params should be enclosed in braces"); + nasm_nonfatal("macro params should be enclosed in braces"); } /* @@ -5233,11 +5170,10 @@ static void pp_cleanup(int pass) if (defining) { if (defining->name) { - nasm_error(ERR_NONFATAL, - "end of file while still defining macro `%s'", - defining->name); + nasm_nonfatal("end of file while still defining macro `%s'", + defining->name); } else { - nasm_error(ERR_NONFATAL, "end of file while still in %%rep"); + nasm_nonfatal("end of file while still in %%rep"); } free_mmacro(defining); @@ -5307,7 +5243,7 @@ static void pp_pre_define(char *definition) if (space->next->type != TOK_PREPROC_ID && space->next->type != TOK_ID) - nasm_error(ERR_WARNING, "pre-defining non ID `%s\'\n", definition); + nasm_warn("pre-defining non ID `%s\'\n", definition); l = nasm_malloc(sizeof(Line)); l->next = predef;