Refactor warning diagnostic code to reduce repeated output logic

This commit is contained in:
Rangi
2026-07-04 23:02:16 -04:00
committed by Rangi
parent de36a11be7
commit 6e643406a2
9 changed files with 174 additions and 253 deletions
+2 -5
View File
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "diagnostics.hpp" // vfatalx
#include "helpers.hpp"
#include "platform.hpp"
#include "style.hpp"
@@ -156,13 +157,9 @@ void Usage::printAndExit(int code) const {
void Usage::printAndExit(char const *fmt, ...) const {
va_list args;
style_Set(stderr, STYLE_RED, true);
fputs("FATAL: ", stderr);
style_Reset(stderr);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
vfatalx(fmt, args);
va_end(args);
putc('\n', stderr);
printAndExit(1);
}