diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-12-13 16:00:44 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-12-13 16:00:44 +0100 |
commit | c9b0a85b088b472eda9818dfaa0cc1a54124933c (patch) | |
tree | 2202fcecec99f2b44ba1754e62f8f1e59c373661 /src/libexpr/parser.y | |
parent | aea97f07a388915e5a7179f56ab4328fef155f05 (diff) |
Restore display of source lines for stdin/string inputs
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r-- | src/libexpr/parser.y | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index ea4e0bfb0..e07909f8e 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -713,10 +713,11 @@ Expr * EvalState::parseExprFromFile(const Path & path, std::shared_ptr<StaticEnv } -Expr * EvalState::parseExprFromString(std::string s, const Path & basePath, std::shared_ptr<StaticEnv> & staticEnv) +Expr * EvalState::parseExprFromString(std::string s_, const Path & basePath, std::shared_ptr<StaticEnv> & staticEnv) { - s.append("\0\0", 2); - return parse(s.data(), s.size(), Pos::string_tag(), basePath, staticEnv); + auto s = make_ref<std::string>(std::move(s_)); + s->append("\0\0", 2); + return parse(s->data(), s->size(), Pos::String{.source = s}, basePath, staticEnv); } @@ -732,7 +733,8 @@ Expr * EvalState::parseStdin() auto buffer = drainFD(0); // drainFD should have left some extra space for terminators buffer.append("\0\0", 2); - return parse(buffer.data(), buffer.size(), Pos::stdin_tag(), absPath("."), staticBaseEnv); + auto s = make_ref<std::string>(std::move(buffer)); + return parse(s->data(), s->size(), Pos::Stdin{.source = s}, absPath("."), staticBaseEnv); } |