nasm.c: better handling of errors without a file without ERR_NOFILE

We have hardcoded ERR_NOFILE in a number of places which really should
not need them, and it represents loss of information.  Instead, be
robust in the handling either of no filename or no line number.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin 2017-12-20 11:32:39 -08:00
parent 29dff5a29e
commit 883985def5

View File

@ -1635,11 +1635,12 @@ static void nasm_verror_gnu(int severity, const char *fmt, va_list ap)
src_get(&lineno, &currentfile);
if (!skip_this_pass(severity)) {
if (currentfile) {
fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno);
} else {
if (!currentfile)
fputs("nasm: ", error_file);
}
else if (!lineno)
fprintf(error_file, "%s: ", currentfile);
else
fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno);
}
nasm_verror_common(severity, fmt, ap);