Allow relative includes in the current directory
This commit is contained in:
parent
12db51e6bb
commit
6d0ab845ea
1 changed files with 10 additions and 4 deletions
|
|
@ -663,20 +663,26 @@ void instance_t::include_directive(char * line)
|
||||||
{
|
{
|
||||||
path filename;
|
path filename;
|
||||||
|
|
||||||
|
DEBUG("textual.include", "include: " << line);
|
||||||
|
|
||||||
if (line[0] != '/' && line[0] != '\\' && line[0] != '~') {
|
if (line[0] != '/' && line[0] != '\\' && line[0] != '~') {
|
||||||
|
DEBUG("textual.include", "received a relative path");
|
||||||
|
DEBUG("textual.include", "parent file path: " << pathname.string());
|
||||||
string::size_type pos = pathname.string().rfind('/');
|
string::size_type pos = pathname.string().rfind('/');
|
||||||
if (pos == string::npos)
|
if (pos == string::npos)
|
||||||
pos = pathname.string().rfind('\\');
|
pos = pathname.string().rfind('\\');
|
||||||
if (pos != string::npos)
|
if (pos != string::npos) {
|
||||||
filename = path(string(pathname.string(), 0, pos + 1)) / line;
|
filename = path(string(pathname.string(), 0, pos + 1)) / line;
|
||||||
|
DEBUG("textual.include", "normalized path: " << filename.string());
|
||||||
|
} else {
|
||||||
|
filename = path(string(".")) / line;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
filename = line;
|
filename = line;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = resolve_path(filename);
|
filename = resolve_path(filename);
|
||||||
|
DEBUG("textual.include", "resolved path: " << filename.string());
|
||||||
DEBUG("textual.include", "Line " << linenum << ": " <<
|
|
||||||
"Including path '" << filename << "'");
|
|
||||||
|
|
||||||
if (! exists(filename))
|
if (! exists(filename))
|
||||||
throw_(std::runtime_error,
|
throw_(std::runtime_error,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue