fixes issue #2446
This commit is contained in:
@@ -620,6 +620,9 @@ static void Assemble (const char* File)
|
|||||||
static void Compile (const char* File)
|
static void Compile (const char* File)
|
||||||
/* Compile the given file */
|
/* Compile the given file */
|
||||||
{
|
{
|
||||||
|
/* A temporary file name passed to the assembler */
|
||||||
|
char *TmpFile = NULL;
|
||||||
|
|
||||||
/* Remember the current compiler argument count */
|
/* Remember the current compiler argument count */
|
||||||
unsigned ArgCount = CC65.ArgCount;
|
unsigned ArgCount = CC65.ArgCount;
|
||||||
|
|
||||||
@@ -657,6 +660,12 @@ static void Compile (const char* File)
|
|||||||
/* Add the file as argument for the compiler */
|
/* Add the file as argument for the compiler */
|
||||||
CmdAddArg (&CC65, File);
|
CmdAddArg (&CC65, File);
|
||||||
|
|
||||||
|
if (DoAssemble && DoLink) {
|
||||||
|
/* set a temporary output file name */
|
||||||
|
TmpFile = MakeTmpFilename(File, ".s");
|
||||||
|
CmdSetOutput (&CC65, TmpFile);
|
||||||
|
}
|
||||||
|
|
||||||
/* Add a NULL pointer to terminate the argument list */
|
/* Add a NULL pointer to terminate the argument list */
|
||||||
CmdAddArg (&CC65, 0);
|
CmdAddArg (&CC65, 0);
|
||||||
|
|
||||||
@@ -671,7 +680,10 @@ static void Compile (const char* File)
|
|||||||
*/
|
*/
|
||||||
if (DoAssemble) {
|
if (DoAssemble) {
|
||||||
/* Assemble the intermediate file and remove it */
|
/* Assemble the intermediate file and remove it */
|
||||||
AssembleIntermediate (File);
|
AssembleIntermediate (TmpFile ? TmpFile : File);
|
||||||
|
if (TmpFile) {
|
||||||
|
xfree(TmpFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
@@ -115,3 +116,23 @@ char* MakeFilename (const char* Origin, const char* Ext)
|
|||||||
}
|
}
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
char* MakeTmpFilename (const char* Origin, const char* Ext)
|
||||||
|
/* Make a new temporary file name from Ext. tmpnam(3) is called
|
||||||
|
** and Ext is appended to generate the filename. Origin is ignored.
|
||||||
|
** The result is placed in a malloc'ed buffer and returned.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
char* Out;
|
||||||
|
char Buffer[L_tmpnam * 2]; /* a lazy way to ensure we have space for Ext */
|
||||||
|
|
||||||
|
tmpnam(Buffer);
|
||||||
|
strcat(Buffer, Ext);
|
||||||
|
|
||||||
|
Out = xmalloc (strlen (Buffer) + 1);
|
||||||
|
strcpy (Out, Buffer);
|
||||||
|
|
||||||
|
return Out;
|
||||||
|
}
|
||||||
|
|||||||
@@ -59,6 +59,12 @@ char* MakeFilename (const char* Origin, const char* Ext);
|
|||||||
** The function may be used to create "foo.o" from "foo.s".
|
** The function may be used to create "foo.o" from "foo.s".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
char* MakeTmpFilename (const char* Origin, const char* Ext);
|
||||||
|
/* Make a new temporary file name from Ext. tmpnam(3) is called
|
||||||
|
** and Ext is appended to generate the filename. Origin is ignored.
|
||||||
|
** The result is placed in a malloc'ed buffer and returned.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of fname.h */
|
/* End of fname.h */
|
||||||
|
|||||||
Reference in New Issue
Block a user