Test for valid destination in uxnasm
This commit is contained in:
parent
035e0d8a3a
commit
8132a09e21
13
src/uxnasm.c
13
src/uxnasm.c
|
@ -412,15 +412,16 @@ cleanup(char *filename)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *src, *dst;
|
||||||
if(argc < 3)
|
if(argc < 3)
|
||||||
return !error("usage", "input.tal output.rom");
|
return !error("usage", "input.tal output.rom");
|
||||||
if(!(f = fopen(argv[1], "r")))
|
if(!(src = fopen(argv[1], "r")))
|
||||||
return !error("Load", "Failed to open source.");
|
return !error("Invalid Input", argv[1]);
|
||||||
if(!pass1(f) || !pass2(f))
|
if(!pass1(src) || !pass2(src))
|
||||||
return !error("Assembly", "Failed to assemble rom.");
|
return !error("Assembly", "Failed to assemble rom.");
|
||||||
fwrite(p.data + TRIM, p.length - TRIM, 1, fopen(argv[2], "wb"));
|
if(!(dst = fopen(argv[2], "wb")))
|
||||||
fclose(f);
|
return !error("Invalid Output", argv[2]);
|
||||||
|
fwrite(p.data + TRIM, p.length - TRIM, 1, dst);
|
||||||
cleanup(argv[2]);
|
cleanup(argv[2]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue