mirror of
https://git.sr.ht/~rabbits/uxn
synced 2024-11-05 05:45:05 +00:00
(uxnasm) Only display location in internal errors
This commit is contained in:
parent
80e2f9cc0c
commit
a5ff070dd0
1 changed files with 12 additions and 5 deletions
17
src/uxnasm.c
17
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]);
|
||||
|
|
Loading…
Reference in a new issue