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:
@@ -102,9 +102,14 @@ int MacPackFind (const StrBuf* Name)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MacPackInsert (int Id)
|
int MacPackInsert (int Id)
|
||||||
/* Insert the macro package with the given id in the input stream */
|
/* Insert the macro package with the given id in the input stream. Returns
|
||||||
{
|
* true if the macro package was found and successfully inserted. Returns
|
||||||
|
* false otherwise.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int RetCode;
|
||||||
|
|
||||||
/* Check the parameter */
|
/* Check the parameter */
|
||||||
CHECK (Id >= 0 && Id < MAC_COUNT);
|
CHECK (Id >= 0 && Id < MAC_COUNT);
|
||||||
|
|
||||||
@@ -116,6 +121,9 @@ void MacPackInsert (int Id)
|
|||||||
/* Insert the builtin package */
|
/* Insert the builtin package */
|
||||||
NewInputData (MacPackages[Id].Package, 0);
|
NewInputData (MacPackages[Id].Package, 0);
|
||||||
|
|
||||||
|
/* Always successful */
|
||||||
|
RetCode = 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
StrBuf Filename = AUTO_STRBUF_INITIALIZER;
|
StrBuf Filename = AUTO_STRBUF_INITIALIZER;
|
||||||
@@ -127,12 +135,15 @@ void MacPackInsert (int Id)
|
|||||||
SB_Terminate (&Filename);
|
SB_Terminate (&Filename);
|
||||||
|
|
||||||
/* Open the macro package as include file */
|
/* Open the macro package as include file */
|
||||||
NewInputFile (SB_GetConstBuf (&Filename));
|
RetCode = NewInputFile (SB_GetConstBuf (&Filename));
|
||||||
|
|
||||||
/* Destroy the contents of Filename */
|
/* Destroy the contents of Filename */
|
||||||
SB_Done (&Filename);
|
SB_Done (&Filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the success code */
|
||||||
|
return RetCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,11 @@ int MacPackFind (const StrBuf* Name);
|
|||||||
* -1 if the package name was not found.
|
* -1 if the package name was not found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void MacPackInsert (int Id);
|
int MacPackInsert (int Id);
|
||||||
/* Insert the macro package with the given id in the input stream */
|
/* Insert the macro package with the given id in the input stream. Returns
|
||||||
|
* true if the macro package was found and successfully inserted. Returns
|
||||||
|
* false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
void MacPackSetDir (const StrBuf* Dir);
|
void MacPackSetDir (const StrBuf* Dir);
|
||||||
/* Set a directory where files for macro packages can be found. Standard is
|
/* Set a directory where files for macro packages can be found. Standard is
|
||||||
|
|||||||
@@ -1146,7 +1146,10 @@ static void DoInclude (void)
|
|||||||
ErrorSkip ("String constant expected");
|
ErrorSkip ("String constant expected");
|
||||||
} else {
|
} else {
|
||||||
SB_Terminate (&SVal);
|
SB_Terminate (&SVal);
|
||||||
NewInputFile (SB_GetConstBuf (&SVal));
|
if (NewInputFile (SB_GetConstBuf (&SVal)) == 0) {
|
||||||
|
/* Error opening the file, skip remainder of line */
|
||||||
|
SkipUntilSep ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1258,8 +1261,12 @@ static void DoMacPack (void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert the package */
|
/* Insert the package. If this fails, skip the remainder of the line to
|
||||||
MacPackInsert (Package);
|
* avoid additional error messages.
|
||||||
|
*/
|
||||||
|
if (MacPackInsert (Package) == 0) {
|
||||||
|
SkipUntilSep ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -429,9 +429,12 @@ static const CharSourceFunctions IFFunc = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void NewInputFile (const char* Name)
|
int NewInputFile (const char* Name)
|
||||||
/* Open a new input file */
|
/* 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;
|
char* PathName = 0;
|
||||||
|
|
||||||
/* First try to open the file */
|
/* First try to open the file */
|
||||||
@@ -450,6 +453,7 @@ void NewInputFile (const char* Name)
|
|||||||
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
|
if (PathName == 0 || (F = fopen (PathName, "r")) == 0) {
|
||||||
/* Not found or cannot open, print an error and bail out */
|
/* Not found or cannot open, print an error and bail out */
|
||||||
Error ("Cannot open include file `%s': %s", Name, strerror (errno));
|
Error ("Cannot open include file `%s': %s", Name, strerror (errno));
|
||||||
|
goto ExitPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use the path name from now on */
|
/* Use the path name from now on */
|
||||||
@@ -495,8 +499,15 @@ void NewInputFile (const char* Name)
|
|||||||
UseCharSource (S);
|
UseCharSource (S);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* File successfully opened */
|
||||||
|
RetCode = 1;
|
||||||
|
|
||||||
|
ExitPoint:
|
||||||
/* Free an allocated name buffer */
|
/* Free an allocated name buffer */
|
||||||
xfree (PathName);
|
xfree (PathName);
|
||||||
|
|
||||||
|
/* Return the success code */
|
||||||
|
return RetCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,10 @@ int IsIdChar (int C);
|
|||||||
int IsIdStart (int C);
|
int IsIdStart (int C);
|
||||||
/* Return true if the character may start an identifier */
|
/* Return true if the character may start an identifier */
|
||||||
|
|
||||||
void NewInputFile (const char* Name);
|
int NewInputFile (const char* Name);
|
||||||
/* Open a new input file */
|
/* Open a new input file. Returns true if the file could be successfully opened
|
||||||
|
* and false otherwise.
|
||||||
|
*/
|
||||||
|
|
||||||
void NewInputData (char* Text, int Malloced);
|
void NewInputData (char* Text, int Malloced);
|
||||||
/* Add a chunk of input data to the input stream */
|
/* Add a chunk of input data to the input stream */
|
||||||
|
|||||||
Reference in New Issue
Block a user