Skip to content

Commit

Permalink
Fixed: Compiling of scripts with #Include <Lib> within an auto-include.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lexikos committed Feb 7, 2012
1 parent 3f701a5 commit d146f0f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions source/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7664,12 +7664,6 @@ Func *Script::FindFuncInLibrary(LPTSTR aFuncName, size_t aFuncNameLength, bool &
SetWorkingDir(sLib[i].path); // See similar section in the #Include directive.
*terminate_here = '\\'; // Undo the termination.

if (!LoadIncludedFile(sLib[i].path, false, false)) // Fix for v1.0.47.05: Pass false for allow-dupe because otherwise, it's possible for a stdlib file to attempt to include itself (especially via the LibNamePrefix_ method) and thus give a misleading "duplicate function" vs. "func does not exist" error message. Obsolete: For performance, pass true for allow-dupe so that it doesn't have to check for a duplicate file (seems too rare to worry about duplicates since by definition, the function doesn't yet exist so it's file shouldn't yet be included).
{
aErrorWasShown = true; // Above has just displayed its error (e.g. syntax error in a line, failed to open the include file, etc). So override the default set earlier.
return NULL;
}

if (mIncludeLibraryFunctionsThenExit && aIsAutoInclude)
{
// For each auto-included library-file, write out two #Include lines:
Expand All @@ -7690,6 +7684,14 @@ Func *Script::FindFuncInLibrary(LPTSTR aFuncName, size_t aFuncNameLength, bool &
, sLib[i].length, sLib[i].path, sLib[i].path);
// Now continue on normally so that our caller can continue looking for syntax errors.
}

// Fix for v1.1.06.00: If the file contains any lib #includes, it must be loaded AFTER the
// above writes sLib[i].path to the iLib file, otherwise the wrong filename could be written.
if (!LoadIncludedFile(sLib[i].path, false, false)) // Fix for v1.0.47.05: Pass false for allow-dupe because otherwise, it's possible for a stdlib file to attempt to include itself (especially via the LibNamePrefix_ method) and thus give a misleading "duplicate function" vs. "func does not exist" error message. Obsolete: For performance, pass true for allow-dupe so that it doesn't have to check for a duplicate file (seems too rare to worry about duplicates since by definition, the function doesn't yet exist so it's file shouldn't yet be included).
{
aErrorWasShown = true; // Above has just displayed its error (e.g. syntax error in a line, failed to open the include file, etc). So override the default set earlier.
return NULL;
}

// Now that a matching filename has been found, it seems best to stop searching here even if that
// file doesn't actually contain the requested function. This helps library authors catch bugs/typos.
Expand Down

0 comments on commit d146f0f

Please sign in to comment.