selfhost/, cmd/, internal/ join the tree-wide sweep: every section banner dies (91 selfhost + the cmd C-style dividers -> 0); narration and stale contracts deleted (pre-#22 bundler notes, retired single-PT_LOAD and no-archive claims, superseded ABI tables); every ref/harec/qbe cite, task cite, encoding/ELF contract, and rule-10 twin pointer kept; lost lifetime/rationale lines restored where the sweep over-cut (elf_globals ownership, kwtab linear-scan). Comment- only proven: all five wwstage tool binaries byte-identical across the sweep; test-commit, test-byteid (161+1399, 0 pinned-divergent), and test-bootstrap (fixed point + 991-995 byte-id) all exit 0. The read-through banked 66 latent-bug leads (checkpoint).
71 lines
1.0 KiB
C
71 lines
1.0 KiB
C
/*
|
|
* Plan 9 style: short, no levels beyond fatal/error/warn, no colour.
|
|
*/
|
|
#include "ww.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
Pos noPos = { "<none>", 0, 0 };
|
|
int nerrors;
|
|
int nwarnings;
|
|
FILE *errout; /* set by main; defaults to stderr */
|
|
|
|
static FILE *
|
|
out(void)
|
|
{
|
|
return errout ? errout : stderr;
|
|
}
|
|
|
|
static void
|
|
prefix(Pos p)
|
|
{
|
|
FILE *f = out();
|
|
if (p.file == NULL)
|
|
p = noPos;
|
|
if (p.line > 0)
|
|
fprintf(f, "%s:%d:%d: ", p.file, p.line, p.col);
|
|
else
|
|
fprintf(f, "%s: ", p.file);
|
|
}
|
|
|
|
void
|
|
fatal(const char *fmt, ...)
|
|
{
|
|
FILE *f = out();
|
|
va_list ap;
|
|
fprintf(f, "ww: ");
|
|
va_start(ap, fmt);
|
|
vfprintf(f, fmt, ap);
|
|
va_end(ap);
|
|
fprintf(f, "\n");
|
|
exit(1);
|
|
}
|
|
|
|
void
|
|
errorf(Pos p, const char *fmt, ...)
|
|
{
|
|
FILE *f = out();
|
|
va_list ap;
|
|
prefix(p);
|
|
fprintf(f, "error: ");
|
|
va_start(ap, fmt);
|
|
vfprintf(f, fmt, ap);
|
|
va_end(ap);
|
|
fprintf(f, "\n");
|
|
nerrors++;
|
|
}
|
|
|
|
void
|
|
warnf(Pos p, const char *fmt, ...)
|
|
{
|
|
FILE *f = out();
|
|
va_list ap;
|
|
prefix(p);
|
|
fprintf(f, "warning: ");
|
|
va_start(ap, fmt);
|
|
vfprintf(f, fmt, ap);
|
|
va_end(ap);
|
|
fprintf(f, "\n");
|
|
nwarnings++;
|
|
}
|