as should return an error if one occurs
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 3 Feb 2001 19:28:32 +0000 (19:28 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 3 Feb 2001 19:28:32 +0000 (19:28 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@569 4a8a32a2-be11-0410-ad9d-d568d2c75423

as/mcs51/asmain.c
as/mcs51/assubr.c

index 8c3d68dc3686c0441f4717a3122e9c4c52e002ff..9dfe59bc9c3142080001439efeb9594e9b253b20 100644 (file)
@@ -15,6 +15,7 @@
 #include <setjmp.h>
 #include <string.h>
 #if !defined(_MSC_VER)
+#include <unistd.h>
 #include <alloc.h>
 #endif
 #include "asm.h"
@@ -149,6 +150,9 @@ extern VOID machine(struct mne *);
  *             REL, LST, and/or SYM files may be generated.
  */
 
+int fatalErrors=0;
+char relFile[128];
+
 int
 main(argc, argv)
 char *argv[];
@@ -243,8 +247,11 @@ char *argv[];
                        if (inpfil == 0) {
                                if (lflag)
                                        lfp = afile(p, "lst", 1);
-                               if (oflag)
-                                       ofp = afile(p, "rel", 1);
+                               if (oflag) {
+                                 ofp = afile(p, "rel", 1);
+                                 // save the file name if we have to delete it on error
+                                 strcpy(relFile,afn);
+                               }
                                if (sflag)
                                        tfp = afile(p, "sym", 1);
                        }
@@ -319,8 +326,10 @@ char *argv[];
        if (lflag) {
                lstsym(lfp);
        }
-       asexit(aserr != 0);
-       return 0;
+       //printf ("aserr: %d\n", aserr);
+       //printf ("fatalErrors: %d\n", fatalErrors);
+       asexit(fatalErrors);
+       return 0; // hush the compiler
 }
 
 /*)Function    VOID    asexit(i)
@@ -365,7 +374,11 @@ int i;
        /*for (j=0; j<MAXINC && ifp[j] != NULL; j++) {
                fclose(ifp[j]);
                }*/
-
+       if (i) {
+         // remove output file
+         printf ("removing %s\n", relFile);
+         unlink(relFile);
+       }
        exit(i);
 }
 
index 95a425e73a09f0d4530bf203b40c5b41bdd7d0e3..786712e99320b17ca2a3d739cb9c004040fbbdfe 100644 (file)
@@ -101,12 +101,15 @@ register int c;
  *             none
  */
 
+extern int fatalErrors;
+
 VOID
 diag()
 {
        register char *p,*errstr;
 
        if (eb != ep) {
+               fatalErrors++;
                p = eb;
                fprintf(stderr, "?ASxxxx-Error-<");
                while (p < ep) {