Skip to content

Commit

Permalink
fix(zscript): support absolute path includes on non-windows too
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Aug 6, 2023
1 parent 5ce129b commit 2b5690b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/parser/ScriptParser.cpp
Expand Up @@ -262,16 +262,24 @@ bool ScriptParser::valid_include(ASTImportDecl& decl, string& ret_fname)
if(!fname)
{
// Scan include paths
int32_t importfound = importname.find_first_not_of("/\\");
if(importfound != string::npos) //If the import is not just `/`'s and `\`'s...
auto ss = std::filesystem::path(importname);
if (std::filesystem::path(importname).is_absolute())
{
if(importfound != 0)
importname = importname.substr(importfound); //Remove leading `/` and `\`
//Convert the include string to a proper import path
fname = checkIncludes(includePath, importname, ZQincludePaths);
if(!fname)
fname = &importname;
}
else
{
int32_t importfound = importname.find_first_not_of("/\\");
if(importfound != string::npos) //If the import is not just `/`'s and `\`'s...
{
fname = checkIncludes(includePath, importname, includePaths);
if(importfound != 0)
importname = importname.substr(importfound); //Remove leading `/` and `\`
//Convert the include string to a proper import path
fname = checkIncludes(includePath, importname, ZQincludePaths);
if(!fname)
{
fname = checkIncludes(includePath, importname, includePaths);
}
}
}
}
Expand Down

0 comments on commit 2b5690b

Please sign in to comment.