mirror of
https://github.com/cc65/cc65.git
synced 2025-04-22 03:38:51 +00:00
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:
parent
df341b6551
commit
30f88d2646
@ -102,9 +102,14 @@ int MacPackFind (const StrBuf* Name)
|
||||
|
||||
|
||||
|
||||
void MacPackInsert (int Id)
|
||||
/* Insert the macro package with the given id in the input stream */
|
||||
{
|
||||
int MacPackInsert (int Id)
|
||||
/* 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 (Id >= 0 && Id < MAC_COUNT);
|
||||
|
||||
@ -116,6 +121,9 @@ void MacPackInsert (int Id)
|
||||
/* Insert the builtin package */
|
||||
NewInputData (MacPackages[Id].Package, 0);
|
||||
|
||||
/* Always successful */
|
||||
RetCode = 1;
|
||||
|
||||
} else {
|
||||
|
||||
StrBuf Filename = AUTO_STRBUF_INITIALIZER;
|
||||
@ -127,12 +135,15 @@ void MacPackInsert (int Id)
|
||||
SB_Terminate (&Filename);
|
||||
|
||||
/* Open the macro package as include file */
|
||||
NewInputFile (SB_GetConstBuf (&Filename));
|
||||
RetCode = NewInputFile (SB_GetConstBuf (&Filename));
|
||||
|
||||
/* Destroy the contents of 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.
|
||||
*/
|
||||
|
||||
void MacPackInsert (int Id);
|
||||
/* Insert the macro package with the given id in the input stream */
|
||||
int MacPackInsert (int Id);
|
||||
/* 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);
|
||||
/* 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");
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
/* Insert the package */
|
||||
MacPackInsert (Package);
|
||||
/* Insert the package. If this fails, skip the remainder of the line to
|
||||
* avoid additional error messages.
|
||||
*/
|
||||
if (MacPackInsert (Package) == 0) {
|
||||
SkipUntilSep ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -78,8 +78,10 @@ int IsIdChar (int C);
|
||||
int IsIdStart (int C);
|
||||
/* Return true if the character may start an identifier */
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
void NewInputData (char* Text, int Malloced);
|
||||
/* Add a chunk of input data to the input stream */
|
||||
|
Loading…
x
Reference in New Issue
Block a user