From a5ff070dd0ec272bb2c4873c3a213960d66ced46 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 1 Mar 2024 17:26:49 -0800 Subject: [PATCH] (uxnasm) Only display location in internal errors --- src/uxnasm.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/uxnasm.c b/src/uxnasm.c index 8d522f1..d761367 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -69,6 +69,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) { @@ -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]);