diff options
author | Marius Kintel <marius@kintel.net> | 2012-01-14 02:25:09 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-01-14 02:25:09 (GMT) |
commit | 10701f71581bd4053ab328254d6abacd6956b498 (patch) | |
tree | 235e93f614c1d2d15d9e6b445a632af5d2f3d2c4 /src | |
parent | 26c9514b70cee4d49ea5441c50dabbda2631e9fa (diff) |
Added absolute path tests to include and use tests, fixed bug using absolute paths in use and include
Diffstat (limited to 'src')
-rw-r--r-- | src/lexer.l | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/lexer.l b/src/lexer.l index 459f92d..718874f 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -108,12 +108,18 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); } [^\t\r\n>]+ { filename = yytext; } ">" { BEGIN(INITIAL); - fs::path usepath = fs::path(parser_source_path) / filename; - if (!fs::exists(usepath)) { - usepath = fs::path(librarydir) / filename; - } - handle_dep(fs::absolute(usepath).string()); - parserlval.text = strdup(fs::absolute(usepath).string().c_str()); + fs::path usepath; + if (fs::path(filename).is_absolute()) { + usepath = filename; + } + else { + usepath = fs::path(parser_source_path) / filename; + if (!fs::exists(usepath)) { + usepath = fs::absolute(fs::path(librarydir) / filename); + } + } + handle_dep(usepath.string()); + parserlval.text = strdup(usepath.string().c_str()); return TOK_USE; } } @@ -192,7 +198,12 @@ void includefile() fs::path dirinfo = sourcepath(); if (!filepath.empty()) { - dirinfo /= filepath; + if (fs::path(filepath).is_absolute()) { + dirinfo = filepath; + } + else { + dirinfo /= filepath; + } } fs::path finfo = dirinfo / filename; |