about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-05-01T09·56+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-05-01T09·56+0000
commit6cecad2be0f7ced82658ec2a86bcf61583487959 (patch)
treee412fb161e0cfac4bffeae6bfd96cff674a0f947 /src/libexpr/primops.cc
parentcce31b739c6d3e381824ac6fde3f06ccb02782af (diff)
* Allow string concatenations involving derivations, e.g.,
    configureFlags = "--with-freetype2-library="
      + freetype + "/lib";

Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 3a291e007f66..8935b147e559 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -109,6 +109,14 @@ static void processBinding(EvalState & state, Expr e, Derivation & drv,
     int n;
     Expr e1, e2;
 
+    if (matchContext(e, es, e2)) {
+        e = e2;
+        for (ATermIterator i(es); i; ++i) {
+            Strings dummy;
+            processBinding(state, *i, drv, dummy);
+        }
+    }
+
     if (matchStr(e, s)) ss.push_back(aterm2String(s));
     else if (matchUri(e, s)) ss.push_back(aterm2String(s));
     else if (e == eTrue) ss.push_back("1");
@@ -408,9 +416,10 @@ ATerm coerceToString(Expr e)
 /* Convert the argument (which can be a path or a uri) to a string. */
 static Expr primToString(EvalState & state, const ATermVector & args)
 {
-    ATerm s = coerceToString(evalExpr(state, args[0]));
-    if (!s) throw Error("cannot coerce value to string");
-    return makeStr(s);
+    ATermList context = ATempty;
+    bool dummy;
+    string s = coerceToStringWithContext(state, context, args[0], dummy);
+    return wrapInContext(context, makeStr(toATerm(s)));
 }