From ba8ec32435313b4749a3733071b3184ca6bd8e14 Mon Sep 17 00:00:00 2001 From: Kunht Kun Date: Wed, 9 Mar 2022 01:26:07 -0500 Subject: 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 --- src/textual.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/textual.cc') 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()); -- cgit v1.2.3