summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-11-10 01:06:04 -0500
committerJohn Wiegley <johnw@newartisans.com>2009-11-10 01:06:04 -0500
commit16a2a16097e356a12feb18a091fd4f19993c350e (patch)
tree92ef4b079f26bec9af0610a9f66330ac93c1328d
parent009b25739728de755892fdc542038c570ba67ba6 (diff)
downloadfork-ledger-16a2a16097e356a12feb18a091fd4f19993c350e.tar.gz
fork-ledger-16a2a16097e356a12feb18a091fd4f19993c350e.tar.bz2
fork-ledger-16a2a16097e356a12feb18a091fd4f19993c350e.zip
Support include-ing of relative pathnames
-rw-r--r--src/textual.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/textual.cc b/src/textual.cc
index ca7aa190..1d8de046 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -608,7 +608,17 @@ void instance_t::xact_directive(char * line, std::streamsize len)
void instance_t::include_directive(char * line)
{
- path filename(line);
+ path filename;
+
+ if (line[0] != '/' && line[0] != '\\' && line[0] != '~') {
+ string::size_type pos = pathname.string().rfind('/');
+ if (pos == string::npos)
+ pos = pathname.string().rfind('\\');
+ if (pos != string::npos)
+ filename = path(string(pathname.string(), 0, pos + 1)) / line;
+ } else {
+ filename = line;
+ }
filename = resolve_path(filename);