multiple input files feature now works again

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40412
This commit is contained in:
David Anderson 2007-01-29 06:43:27 +00:00
parent af651e15f3
commit 52b45354e8

View File

@ -170,6 +170,8 @@ static int *wqptr; /* pointer to next entry */
static HWND hwndFinish = 0; static HWND hwndFinish = 0;
#endif #endif
char g_tmpfile[_MAX_PATH] = {0};
/* "main" of the compiler /* "main" of the compiler
*/ */
#if defined __cplusplus #if defined __cplusplus
@ -263,20 +265,22 @@ int pc_compile(int argc, char *argv[])
unsigned char tstring[128]; unsigned char tstring[128];
fsrc=(FILE*)pc_opensrc(sname); fsrc=(FILE*)pc_opensrc(sname);
if (fsrc==NULL) { if (fsrc==NULL) {
pc_closesrc(ftmp);
remove(tname);
strcpy(inpfname,sname); /* avoid invalid filename */ strcpy(inpfname,sname); /* avoid invalid filename */
error(100,sname); error(100,sname);
} /* if */ } /* if */
pc_writesrc(ftmp,(unsigned char*)"#file "); pc_writesrc(ftmp,(unsigned char*)"#file \"");
pc_writesrc(ftmp,(unsigned char*)sname); pc_writesrc(ftmp,(unsigned char*)sname);
pc_writesrc(ftmp,(unsigned char*)"\n"); pc_writesrc(ftmp,(unsigned char*)"\"\n");
while (!pc_eofsrc(fsrc)) { while (!pc_eofsrc(fsrc) && pc_readsrc(fsrc,tstring,sizeof tstring)) {
pc_readsrc(fsrc,tstring,sizeof tstring);
pc_writesrc(ftmp,tstring); pc_writesrc(ftmp,tstring);
} /* while */ } /* while */
pc_closesrc(fsrc); pc_closesrc(fsrc);
} /* for */ } /* for */
pc_closesrc(ftmp); pc_closesrc(ftmp);
strcpy(inpfname,tname); strcpy(inpfname,tname);
strcpy(g_tmpfile,tname);
free(tname); free(tname);
} else { } else {
strcpy(inpfname,get_sourcefile(0)); strcpy(inpfname,get_sourcefile(0));
@ -481,9 +485,10 @@ cleanup:
} /* if */ } /* if */
#endif #endif
if (g_tmpfile[0] != '\0') {
remove(g_tmpfile);
}
if (inpfname!=NULL) { if (inpfname!=NULL) {
if (get_sourcefile(1)!=NULL)
remove(inpfname); /* the "input file" was in fact a temporary file */
free(inpfname); free(inpfname);
} /* if */ } /* if */
if (litq!=NULL) if (litq!=NULL)