uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit a5ff070dd0ec272bb2c4873c3a213960d66ced46
parent 80e2f9cc0c0b6d87d8b2b15160066009d7aaa8a1
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Fri,  1 Mar 2024 17:26:49 -0800

(uxnasm) Only display location in internal errors

Diffstat:
Msrc/uxnasm.c | 17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/uxnasm.c b/src/uxnasm.c @@ -70,6 +70,13 @@ static char *scat(char *dst, const char *src) { char *ptr = dst + slen(dst); whi static int parse(char *w, FILE *f); static int +error_top(const char *name, const char *msg) +{ + fprintf(stderr, "%s: %s\n", name, msg); + return 0; +} + +static int error(const char *name, const char *msg) { fprintf(stderr, "%s: %s in %s:\n", name, msg, p.location); @@ -520,17 +527,17 @@ main(int argc, char *argv[]) { FILE *src, *dst; if(argc == 1) - return error("usage", "uxnasm [-v] input.tal output.rom"); + return error_top("usage", "uxnasm [-v] input.tal output.rom"); if(argv[1][0] == '-' && argv[1][1] == 'v') return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 1 Mar 2024.\n"); if(!(src = fopen(setlocation(argv[1]), "r"))) - return !error("Invalid input", argv[1]); + return !error_top("Invalid input", argv[1]); if(!assemble(src)) - return !error("Assembly", "Failed to assemble rom."); + return !error_top("Assembly", "Failed to assemble rom."); if(!(dst = fopen(argv[2], "wb"))) - return !error("Invalid Output", argv[2]); + return !error_top("Invalid Output", argv[2]); if(p.length <= TRIM) - return !error("Assembly", "Output rom is empty."); + return !error_top("Assembly", "Output rom is empty."); fwrite(p.data + TRIM, p.length - TRIM, 1, dst); if(!scmp(argv[2], "-", 2)) { review(argv[2]);