Fix idParser::Directive_include() to properly handle full os path as fetched by idLexer::GetFileName()

This commit is contained in:
Stephen Saunders 2023-01-07 22:53:11 -05:00
parent 1c4883354b
commit 7485a123f6

View file

@ -1150,11 +1150,18 @@ int idParser::Directive_include( idToken* token, bool supressWarning )
// try relative to the current file
path = scriptstack->GetFileName();
path.StripFilename();
path += "/";
path += *token;
if( !script->LoadFile( path, OSPath ) )
// first remove any trailing path overlap with token
idStr token_path = *token;
if( !path.StripTrailingOnce( token_path.StripFilename() ) )
{
// try absolute path
// if no path overlap add separator before token
path += "/";
}
path += *token;
// try assuming a full os path from GetFileName()
if( !script->LoadFile( path, true ) )
{
// try from the token path
path = *token;
if( !script->LoadFile( path, OSPath ) )
{