summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2016-10-03 09:18:13 -0700
committerGitHub <noreply@github.com>2016-10-03 09:18:13 -0700
commitd4d0334a3b1b4ba24d540c21eb157a5e1b36d189 (patch)
treed95710a5ff7600576a6db59a04f4e91eb9ab591f /src
parent3ebe330bf1b72036e36ad69a14fceb658ebc8051 (diff)
parent2dbafc53fda39943ba717ca69df03cb2bdeed396 (diff)
downloadfork-ledger-d4d0334a3b1b4ba24d540c21eb157a5e1b36d189.tar.gz
fork-ledger-d4d0334a3b1b4ba24d540c21eb157a5e1b36d189.tar.bz2
fork-ledger-d4d0334a3b1b4ba24d540c21eb157a5e1b36d189.zip
Merge pull request #471 from schmave/win-path
Use boost parent_path() method instead of manual computation
Diffstat (limited to 'src')
-rw-r--r--src/textual.cc13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/textual.cc b/src/textual.cc
index 4549581b..7ef5c7eb 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -721,15 +721,12 @@ void instance_t::include_directive(char * line)
if (line[0] != '/' && line[0] != '\\' && line[0] != '~') {
DEBUG("textual.include", "received a relative path");
DEBUG("textual.include", "parent file path: " << context.pathname);
- string pathstr(context.pathname.string());
- string::size_type pos = pathstr.rfind('/');
- if (pos == string::npos)
- pos = pathstr.rfind('\\');
- if (pos != string::npos) {
- filename = path(string(pathstr, 0, pos + 1)) / line;
- DEBUG("textual.include", "normalized path: " << filename.string());
- } else {
+ path parent_path = context.pathname.parent_path();
+ if (parent_path.empty()) {
filename = path(string(".")) / line;
+ } else {
+ filename = parent_path / line;
+ DEBUG("textual.include", "normalized path: " << filename.string());
}
} else {
filename = line;