Implement -X/--max-errors for RGBASM (#1262)

Co-authored-by: Eldred Habert <me@eldred.fr>
This commit is contained in:
Rangi
2023-12-07 05:42:47 -05:00
committed by GitHub
parent 1fa289f2ee
commit 34b2543c8b
9 changed files with 47 additions and 5 deletions

View File

@@ -16,6 +16,7 @@
#include "itertools.hpp"
unsigned int nbErrors = 0;
unsigned int maxErrors = 0;
static const enum WarningState defaultWarnings[ARRAY_SIZE(warningStates)] = {
AT(WARNING_ASSERT) WARNING_ENABLED,
@@ -343,7 +344,12 @@ void error(char const *fmt, ...)
va_start(args, fmt);
printDiag(fmt, args, "error: ", ":\n ", NULL);
va_end(args);
// This intentionally makes 0 act as "unlimited" (or at least "limited to sizeof(unsigned)")
nbErrors++;
if (nbErrors == maxErrors)
errx("The maximum of %u error%s was reached (configure with \"-X/--max-errors\"); assembly aborted!",
maxErrors, maxErrors == 1 ? "" : "s");
}
[[noreturn]] void fatalerror(char const *fmt, ...)