diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-29T10·43+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2003-07-29T10·43+0000 |
commit | 79ba0431db223c1c08b46e8f3d1819e3457f21a0 (patch) | |
tree | d1d95370475a85bf9008f442489d7461f06f1d10 /src/normalise.cc | |
parent | 5acb45446e756c023bcb6f052331181671580a5e (diff) |
* `fstateRefs' now works on derive expressions as well. TODO: make
this more efficient. * A flag `-n' in 'nix --query' to normalise the argument. Default is not to normalise.
Diffstat (limited to 'src/normalise.cc')
-rw-r--r-- | src/normalise.cc | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/normalise.cc b/src/normalise.cc index 95d96351af54..eefb790b6f98 100644 --- a/src/normalise.cc +++ b/src/normalise.cc @@ -217,12 +217,11 @@ void realiseSlice(const FSId & id, FSIdSet pending) } -Strings fstatePaths(const FSId & id, bool normalise) +Strings fstatePaths(const FSId & id) { Strings paths; - FState fs = parseFState(termFromId( - normalise ? normaliseFState(id) : id)); + FState fs = parseFState(termFromId(id)); if (fs.type == FState::fsSlice) { /* !!! fix complexity */ @@ -245,14 +244,31 @@ Strings fstatePaths(const FSId & id, bool normalise) } +static void fstateRefsSet(const FSId & id, StringSet & paths) +{ + FState fs = parseFState(termFromId(id)); + + if (fs.type == FState::fsSlice) { + for (SliceElems::iterator i = fs.slice.elems.begin(); + i != fs.slice.elems.end(); i++) + paths.insert(i->path); + } + + else if (fs.type == FState::fsDerive) { + for (FSIds::iterator i = fs.derive.inputs.begin(); + i != fs.derive.inputs.end(); i++) + fstateRefsSet(*i, paths); + } + + else abort(); +} + + Strings fstateRefs(const FSId & id) { - Strings paths; - FState fs = parseFState(termFromId(normaliseFState(id))); - for (SliceElems::const_iterator i = fs.slice.elems.begin(); - i != fs.slice.elems.end(); i++) - paths.push_back(i->path); - return paths; + StringSet paths; + fstateRefsSet(id, paths); + return Strings(paths.begin(), paths.end()); } |