shithub: rgbds

Download patch

ref: c8fa7998838199d1f1d3ae7ec94fcad58515fa02
parent: 7f37eef2186d36dcb68f263054e27f410bb2c37b
author: Antonio Niño Díaz <[email protected]>
date: Mon Jan 15 15:28:36 EST 2018

Output error msg when object file can't be opened

In rgbasm, output a fatal error if the destination object file can't be
opened.

Signed-off-by: Antonio Niño Díaz <[email protected]>

--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -522,31 +522,36 @@
 
 	addexports();
 
+	/* If no path specified, don't write file */
+	if (tzObjectname == NULL)
+		return;
+
 	f = fopen(tzObjectname, "wb");
-	if (f != NULL) {
-		struct PatchSymbol *pSym;
-		struct Section *pSect;
+	if (f == NULL)
+		fatalerror("Couldn't write file '%s'\n", tzObjectname);
 
-		fwrite(RGBDS_OBJECT_VERSION_STRING, 1,
-		       strlen(RGBDS_OBJECT_VERSION_STRING), f);
+	struct PatchSymbol *pSym;
+	struct Section *pSect;
 
-		fputlong(countsymbols(), f);
-		fputlong(countsections(), f);
+	fwrite(RGBDS_OBJECT_VERSION_STRING, 1,
+	       strlen(RGBDS_OBJECT_VERSION_STRING), f);
 
-		pSym = pPatchSymbols;
-		while (pSym) {
-			writesymbol(pSym->pSymbol, f);
-			pSym = pSym->pNext;
-		}
+	fputlong(countsymbols(), f);
+	fputlong(countsections(), f);
 
-		pSect = pSectionList;
-		while (pSect) {
-			writesection(pSect, f);
-			pSect = pSect->pNext;
-		}
+	pSym = pPatchSymbols;
+	while (pSym) {
+		writesymbol(pSym->pSymbol, f);
+		pSym = pSym->pNext;
+	}
 
-		fclose(f);
+	pSect = pSectionList;
+	while (pSect) {
+		writesection(pSect, f);
+		pSect = pSect->pNext;
 	}
+
+	fclose(f);
 }
 
 /*