if (!dumpFilesPtr->filePtr) {
// not used before, create it
- strcpy (buffer, srcFileName);
- strcat (buffer, dumpFilesPtr->ext);
- if (!(dumpFilesPtr->filePtr = fopen (buffer, "w"))) {
- werror (E_FILE_OPEN_ERR, buffer);
+ strcpy (scratchFileName, srcFileName);
+ strcat (scratchFileName, dumpFilesPtr->ext);
+ if (!(dumpFilesPtr->filePtr = fopen (scratchFileName, "w"))) {
+ werror (E_FILE_OPEN_ERR, scratchFileName);
exit (1);
}
- //dprintf ("created: %s\n", buffer);
- } else {
- //dprintf ("appended: %s%s\n", srcFileName, dumpFilesPtr->ext);
- }
+ }
return dumpFilesPtr->filePtr;
}
extern int nlibFiles;
extern bool verboseExec ;
-/*
- void buildCmdLine(char *into, char **args, const char **cmds,
- const char *p1, const char *p2,
- const char *p3, const char **list);
- int my_system (const char *cmd, char **cmd_argv);
- */
-
void parseWithComma (char **, char *);
/** Creates a temporary file a'la tmpfile which avoids the bugs
extern struct _dumpFiles dumpFiles[];
+/* Buffer which can be used to hold a file name; assume it will
+ * be trashed by any function call within SDCC.
+ */
+extern char scratchFileName[FILENAME_MAX];
+
#endif
if (!options.c1mode)
{
- sprintf (buffer, srcFileName);
- strcat (buffer, port->assembler.file_ext);
+ sprintf (scratchFileName, srcFileName);
+ strcat (scratchFileName, port->assembler.file_ext);
}
else
{
- strcpy (buffer, options.out_name);
+ strcpy (scratchFileName, options.out_name);
}
- if (!(asmFile = fopen (buffer, "w")))
+ if (!(asmFile = fopen (scratchFileName, "w")))
{
- werror (E_FILE_OPEN_ERR, buffer);
+ werror (E_FILE_OPEN_ERR, scratchFileName);
exit (1);
}
bool verboseExec = FALSE;
char *preOutName;
+// Globally accessible scratch buffer for file names.
+char scratchFileName[FILENAME_MAX];
+
// In MSC VC6 default search path for exe's to path for this
char DefaultExePath[128];
parseCmdLine (int argc, char **argv)
{
int i;
- char cdbfnbuf[50];
/* go thru all whole command line */
for (i = 1; i < argc; i++)
/* if debug option is set the open the cdbFile */
if (!options.nodebug && srcFileName)
{
- sprintf (cdbfnbuf, "%s.cdb", srcFileName);
- if ((cdbFile = fopen (cdbfnbuf, "w")) == NULL)
- werror (E_FILE_OPEN_ERR, cdbfnbuf);
+ sprintf (scratchFileName, "%s.cdb", srcFileName);
+ if ((cdbFile = fopen (scratchFileName, "w")) == NULL)
+ werror (E_FILE_OPEN_ERR, scratchFileName);
else
{
/* add a module record */
srcFileName = "temp";
/* first we need to create the <filename>.lnk file */
- sprintf (buffer, "%s.lnk", srcFileName);
- if (!(lnkfile = fopen (buffer, "w")))
+ sprintf (scratchFileName, "%s.lnk", srcFileName);
+ if (!(lnkfile = fopen (scratchFileName, "w")))
{
- werror (E_FILE_OPEN_ERR, buffer);
+ werror (E_FILE_OPEN_ERR, scratchFileName);
exit (1);
}
}
if (preProcOnly)
+ {
exit (0);
+ }
}
else
{
sz = "a";
/* first we need to create the <filename>.lnk file */
- sprintf (buffer, "%s.lnk", sz);
- if (!(lnkfile = fopen (buffer, "w")))
+ sprintf (scratchFileName, "%s.lnk", sz);
+ if (!(lnkfile = fopen (scratchFileName, "w")))
{
- werror (E_FILE_OPEN_ERR, buffer);
+ werror (E_FILE_OPEN_ERR, scratchFileName);
exit (1);
}