about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-12-02T11·47+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-12-02T11·47+0000
commit49f59dceca37636353cf2f5f60135d7705ea154e (patch)
treeb6b26acd615b96ed0f53089941391d6a5cad864b /src/libexpr/primops.cc
parentb12b21825c949ef9b9327c6a0c9e2d5601aaf0b2 (diff)
* Move parseHash16or32 into libutil, and use in nix-hash.
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc12
1 files changed, 1 insertions, 11 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 0e81f7b72f..66173cdaf0 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -401,17 +401,7 @@ static void prim_derivationStrict(EvalState & state, Value * * args, Value & v)
         HashType ht = parseHashType(outputHashAlgo);
         if (ht == htUnknown)
             throw EvalError(format("unknown hash algorithm `%1%'") % outputHashAlgo);
-        Hash h(ht);
-        if (outputHash.size() == h.hashSize * 2)
-            /* hexadecimal representation */
-            h = parseHash(ht, outputHash);
-        else if (outputHash.size() == hashLength32(h))
-            /* base-32 representation */
-            h = parseHash32(ht, outputHash);
-        else
-            throw Error(format("hash `%1%' has wrong length for hash type `%2%'")
-                % outputHash % outputHashAlgo);
-        string s = outputHash;
+        Hash h = parseHash16or32(ht, outputHash);
         outputHash = printHash(h);
         if (outputHashRecursive) outputHashAlgo = "r:" + outputHashAlgo;