summaryrefslogtreecommitdiff
path: root/src/textual.cc
diff options
context:
space:
mode:
authorKunht Kun <kunhtkun@gmail.com>2022-03-09 01:26:07 -0500
committerMartin Michlmayr <tbm@cyrius.com>2022-03-09 19:34:11 +0800
commitba8ec32435313b4749a3733071b3184ca6bd8e14 (patch)
tree9a70f5b6ba76688270f270ba3b9702d71677a1fa /src/textual.cc
parent474d2b8d091ba865c17c554a4ecdfb0d05325d3f (diff)
downloadfork-ledger-ba8ec32435313b4749a3733071b3184ca6bd8e14.tar.gz
fork-ledger-ba8ec32435313b4749a3733071b3184ca6bd8e14.tar.bz2
fork-ledger-ba8ec32435313b4749a3733071b3184ca6bd8e14.zip
Ensure absolute path for include
Ensure the path of file to include in `instance_t::include_directive` is always an absolute path. Previously when the journal file is given through stdin, we prepend a "./" to the filename to include. However, in Boost >= 1.77, `path::normalize` strips the leading "./" [1]. Our `resolve_path` function calls `normalize` and thus now it returns "file" for "./file" instead of the previous "./file". This change causes a failing test regress/BF3C1F82-2 [2], and also breaks the `include` directive for stdin input: $ touch file-to-include $ echo "include file-to-include" | ledger -f - reg gives While parsing file "", line 1: Error: File to include was not found: "file-to-include" Therefore, we change to prepend the `context.current_directory` to make the filename absolute in this case as well. The test regress/BF3C1F82-2 is also updated to match the new output. Fixes #2075. [1] https://github.com/boostorg/filesystem/commit/16bd89b7c0398d0dc5904148a865ef3fc3ece7ec [2] https://github.com/ledger/ledger/issues/2075
Diffstat (limited to 'src/textual.cc')
-rw-r--r--src/textual.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/textual.cc b/src/textual.cc
index bc91ef52..b2108dcf 100644
--- a/src/textual.cc
+++ b/src/textual.cc
@@ -743,7 +743,7 @@ void instance_t::include_directive(char * line)
DEBUG("textual.include", "parent file path: " << context.pathname);
path parent_path = context.pathname.parent_path();
if (parent_path.empty()) {
- filename = path(string(".")) / line;
+ filename = context.current_directory / line;
} else {
filename = parent_path / line;
DEBUG("textual.include", "normalized path: " << filename.string());