about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-05-01T14·01+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-05-01T14·01+0000
commit0064599a27ec44880e4ff6fa19f453e610b5ef07 (patch)
tree50289edc19dc99d5423ce8f57b99c5b8eb5597c1 /src/libexpr/eval.cc
parent6cecad2be0f7ced82658ec2a86bcf61583487959 (diff)
* String interpolation. Expressions like
    "--with-freetype2-library=" + freetype + "/lib"

  can now be written as

    "--with-freetype2-library=${freetype}/lib"

  An arbitrary expression can be enclosed within ${...}, not just
  identifiers.

* Escaping in string literals: \n, \r, \t interpreted as in C, any
  other character following \ is interpreted as-is.
  
* Newlines are now allowed in string literals.

Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 1c2aafd91fc9..d70ac9f76a23 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -231,7 +231,7 @@ static ATerm concatStrings(EvalState & state, const ATermVector & args)
 {
     ATermList context = ATempty;
     ostringstream s;
-    bool isPath;
+    bool isPath = false;
 
     for (ATermVector::const_iterator i = args.begin(); i != args.end(); ++i) {
         bool isPath2;
@@ -449,6 +449,14 @@ Expr evalExpr2(EvalState & state, Expr e)
         return makeList(ATconcat(l1, l2));
     }
 
+    /* String concatenation. */
+    ATermList es;
+    if (matchConcatStrings(e, es)) {
+        ATermVector args;
+        for (ATermIterator i(es); i; ++i) args.push_back(*i);
+        return concatStrings(state, args);
+    }
+
     /* Barf. */
     throw badTerm("invalid expression", e);
 }