diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-03-22 10:29:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-22 10:29:46 +0100 |
commit | e4ff4308665614202123ac9b46f2f9921ff41e47 (patch) | |
tree | 4b9898174663e7d644e4992563c4593a6eb3b9f4 /src/libexpr/eval.cc | |
parent | 7ed81701ee5da8c49f31bf0bbe3bca3645cf37bc (diff) | |
parent | 4d6a3806d24b54f06ddc0cf234ac993db028cf29 (diff) |
Merge pull request #6237 from obsidiansystems/store-path-string-context
Decode string context straight to using StorePaths
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index c65ef9738..f7911e32b 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1903,13 +1903,22 @@ std::string_view EvalState::forceString(Value & v, const Pos & pos) /* Decode a context string ‘!<name>!<path>’ into a pair <path, name>. */ -std::pair<std::string, std::string> decodeContext(std::string_view s) +NixStringContextElem decodeContext(const Store & store, std::string_view s) { if (s.at(0) == '!') { size_t index = s.find("!", 1); - return {std::string(s.substr(index + 1)), std::string(s.substr(1, index - 1))}; + return { + store.parseStorePath(s.substr(index + 1)), + std::string(s.substr(1, index - 1)), + }; } else - return {s.at(0) == '/' ? std::string(s) : std::string(s.substr(1)), ""}; + return { + store.parseStorePath( + s.at(0) == '/' + ? s + : s.substr(1)), + "", + }; } @@ -1921,13 +1930,13 @@ void copyContext(const Value & v, PathSet & context) } -std::vector<std::pair<Path, std::string>> Value::getContext() +NixStringContext Value::getContext(const Store & store) { - std::vector<std::pair<Path, std::string>> res; + NixStringContext res; assert(internalType == tString); if (string.context) for (const char * * p = string.context; *p; ++p) - res.push_back(decodeContext(*p)); + res.push_back(decodeContext(store, *p)); return res; } |