aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/builtins/buildenv.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-04 05:16:42 +0100
committereldritch horrors <pennae@lix.systems>2024-03-04 05:16:42 +0100
commit8abb20390ef2f8ae664c0ac34479b2a43aa1df26 (patch)
treef56c81ea799d3d543748b8deec5892f3aed8992b /src/libstore/builtins/buildenv.cc
parentea10088703d1d7f83c27e4ff14ae98543f7fc47d (diff)
Merge pull request #9229 from tfc/small-improvements
Remove warnings, small improvements (cherry picked from commit 5ac87a75dd65c19c50976559a6f7810c315cd9d5) Change-Id: I88349b6e954398dde83c845f42d41a9dd89ba9e0
Diffstat (limited to 'src/libstore/builtins/buildenv.cc')
-rw-r--r--src/libstore/builtins/buildenv.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libstore/builtins/buildenv.cc b/src/libstore/builtins/buildenv.cc
index 7bba33fb9..c8911d153 100644
--- a/src/libstore/builtins/buildenv.cc
+++ b/src/libstore/builtins/buildenv.cc
@@ -174,15 +174,19 @@ void builtinBuildenv(const BasicDerivation & drv)
/* Convert the stuff we get from the environment back into a
* coherent data type. */
Packages pkgs;
- auto derivations = tokenizeString<Strings>(getAttr("derivations"));
- while (!derivations.empty()) {
- /* !!! We're trusting the caller to structure derivations env var correctly */
- auto active = derivations.front(); derivations.pop_front();
- auto priority = stoi(derivations.front()); derivations.pop_front();
- auto outputs = stoi(derivations.front()); derivations.pop_front();
- for (auto n = 0; n < outputs; n++) {
- auto path = derivations.front(); derivations.pop_front();
- pkgs.emplace_back(path, active != "false", priority);
+ {
+ auto derivations = tokenizeString<Strings>(getAttr("derivations"));
+
+ auto itemIt = derivations.begin();
+ while (itemIt != derivations.end()) {
+ /* !!! We're trusting the caller to structure derivations env var correctly */
+ const bool active = "false" != *itemIt++;
+ const int priority = stoi(*itemIt++);
+ const size_t outputs = stoul(*itemIt++);
+
+ for (size_t n {0}; n < outputs; n++) {
+ pkgs.emplace_back(std::move(*itemIt++), active, priority);
+ }
}
}