diff options
author | Evan Mallory <schmave@gmail.com> | 2016-10-02 20:13:43 -0400 |
---|---|---|
committer | Evan Mallory <schmave@gmail.com> | 2016-10-02 20:17:34 -0400 |
commit | 2dbafc53fda39943ba717ca69df03cb2bdeed396 (patch) | |
tree | e0becd93e007899636ea5710496bc3272e11dfbf /src/textual.cc | |
parent | cd58d43228996198b5ba329f7c05109f2aaee65a (diff) | |
download | fork-ledger-2dbafc53fda39943ba717ca69df03cb2bdeed396.tar.gz fork-ledger-2dbafc53fda39943ba717ca69df03cb2bdeed396.tar.bz2 fork-ledger-2dbafc53fda39943ba717ca69df03cb2bdeed396.zip |
Use boost parent_path() method instead of manual computation
This fixes error-in-include.test, dir-apply.test, 6188B0EC.test, and 89233B6D.test when running under msys2 on Windows. The manual computation is incorrect when there are both forward slash and backward slash characters in the path.
Diffstat (limited to 'src/textual.cc')
-rw-r--r-- | src/textual.cc | 13 |
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; |