summaryrefslogtreecommitdiff
path: root/src/textual.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-12-07 20:43:17 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-12-07 20:43:17 -0500
commit6d0ab845eaec51946190c847f1ad08f910e5a003 (patch)
treefed571b82fb2a282eae7dcf6739c56904faa2f70 /src/textual.cc
parent12db51e6bb8876102ab2d535d77869981411176d (diff)
downloadfork-ledger-6d0ab845eaec51946190c847f1ad08f910e5a003.tar.gz
fork-ledger-6d0ab845eaec51946190c847f1ad08f910e5a003.tar.bz2
fork-ledger-6d0ab845eaec51946190c847f1ad08f910e5a003.zip
Allow relative includes in the current directory
Diffstat (limited to 'src/textual.cc')
-rw-r--r--src/textual.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/textual.cc b/src/textual.cc
index cf670cae..c5a6d896 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -663,20 +663,26 @@ void instance_t::include_directive(char * line)
{
path filename;
+ DEBUG("textual.include", "include: " << line);
+
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('/');
if (pos == string::npos)
pos = pathname.string().rfind('\\');
- if (pos != string::npos)
+ if (pos != string::npos) {
filename = path(string(pathname.string(), 0, pos + 1)) / line;
+ DEBUG("textual.include", "normalized path: " << filename.string());
+ } else {
+ filename = path(string(".")) / line;
+ }
} else {
filename = line;
}
filename = resolve_path(filename);
-
- DEBUG("textual.include", "Line " << linenum << ": " <<
- "Including path '" << filename << "'");
+ DEBUG("textual.include", "resolved path: " << filename.string());
if (! exists(filename))
throw_(std::runtime_error,