summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-12-10 13:04:33 -0800
committerH. Peter Anvin <hpa@zytor.com>2018-12-10 13:06:48 -0800
commit070c50fe72d79822d1986ba499b5a141dcd38c4d (patch)
treee5a9073643f90dde580149a4ac4ececad268f7d3
parent3475462ee87fdd59af715fa0c28eecc4672466fb (diff)
downloadnasm-070c50fe72d79822d1986ba499b5a141dcd38c4d.tar.gz
nasm: clean up error messages somewhat
If warnings are errors, print [-w+error=xxxx] and prefix error:. Use the same spacing for filename and non-filename error messages. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--asm/nasm.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/asm/nasm.c b/asm/nasm.c
index 445bc367..fb205800 100644
--- a/asm/nasm.c
+++ b/asm/nasm.c
@@ -1754,7 +1754,7 @@ static void nasm_verror_gnu(int severity, const char *fmt, va_list ap)
if (!skip_this_pass(severity)) {
if (!lineno)
- fprintf(error_file, "%s:", currentfile ? currentfile : "nasm");
+ fprintf(error_file, "%s: ", currentfile ? currentfile : "nasm");
else
fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno);
}
@@ -1789,10 +1789,10 @@ static void nasm_verror_vc(int severity, const char *fmt, va_list ap)
src_get(&lineno, &currentfile);
if (!skip_this_pass(severity)) {
- if (currentfile) {
+ if (lineno) {
fprintf(error_file, "%s(%"PRId32") : ", currentfile, lineno);
} else {
- fputs("nasm: ", error_file);
+ fprintf(error_file , "%s : ", currentfile ? currentfile : "nasm");
}
}
@@ -1869,11 +1869,16 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args)
{
char msg[1024];
const char *pfx;
+ bool warn_is_err = warning_is_error(severity);
+ bool warn_is_other = WARN_IDX(severity) == ERR_WARN_OTHER;
switch (severity & (ERR_MASK|ERR_NO_SEVERITY)) {
case ERR_WARNING:
- pfx = "warning: ";
- break;
+ if (!warn_is_err) {
+ pfx = "warning: ";
+ break;
+ }
+ /* fall through */
case ERR_NONFATAL:
pfx = "error: ";
break;
@@ -1892,9 +1897,11 @@ static void nasm_verror_common(int severity, const char *fmt, va_list args)
}
vsnprintf(msg, sizeof msg - 64, fmt, args);
- if (is_valid_warning(severity) && WARN_IDX(severity) != ERR_WARN_OTHER) {
+ if (is_valid_warning(severity) && (warn_is_err || !warn_is_other)) {
char *p = strchr(msg, '\0');
- snprintf(p, 64, " [-w+%s]", warnings[WARN_IDX(severity)].name);
+ snprintf(p, 64, " [-w+%s%s]",
+ warn_is_err ? "error=" : "",
+ warnings[WARN_IDX(severity)].name);
}
if (!skip_this_pass(severity))