Avoid spurious subsequent errors if an include file wasn't found.

git-svn-id: svn://svn.cc65.org/cc65/trunk@3908 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2009-01-18 15:07:55 +00:00
parent df341b6551
commit 30f88d2646
5 changed files with 47 additions and 13 deletions

View File

@@ -429,9 +429,12 @@ static const CharSourceFunctions IFFunc = {
void NewInputFile (const char* Name)
/* Open a new input file */
int NewInputFile (const char* Name)
/* Open a new input file. Returns true if the file could be successfully opened
* and false otherwise.
*/
{
int RetCode = 0; /* Return code. Assume an error. */
char* PathName = 0;
/* First try to open the file */
@@ -450,6 +453,7 @@ void NewInputFile (const char* Name)
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
/* Not found or cannot open, print an error and bail out */
Error ("Cannot open include file `%s': %s", Name, strerror (errno));
goto ExitPoint;
}
/* Use the path name from now on */
@@ -495,8 +499,15 @@ void NewInputFile (const char* Name)
UseCharSource (S);
}
/* File successfully opened */
RetCode = 1;
ExitPoint:
/* Free an allocated name buffer */
xfree (PathName);
/* Return the success code */
return RetCode;
}