From 2c10d72eff141275bf058e9f7668d17df6f8d25a Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Wed, 27 Nov 2013 17:36:53 +0900 Subject: [PATCH] STRING_LITERAL could contain expandable expressions, so evaluate them too. We cannot simply "expand strings first then evaluate condition as boolean" because there are things like "$(A)=='true'" which is expanded as "=='true'". --- .../Microsoft.Build.Internal/ExpressionEvaluator.cs | 2 +- .../Microsoft.Build.Internal/ExpressionParserManual.cs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionEvaluator.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionEvaluator.cs index e89a45f9b22..ffaeb39234e 100644 --- a/mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionEvaluator.cs +++ b/mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionEvaluator.cs @@ -440,7 +440,7 @@ namespace Microsoft.Build.Internal.Expressions public override string EvaluateAsString (EvaluationContext context) { - return this.Value.Name; + return context.Evaluator.Evaluate (this.Value.Name); } public override object EvaluateAsObject (EvaluationContext context) diff --git a/mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionParserManual.cs b/mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionParserManual.cs index 81a570c6adf..2c376a3dda0 100644 --- a/mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionParserManual.cs +++ b/mcs/class/Microsoft.Build/Microsoft.Build.Internal/ExpressionParserManual.cs @@ -58,8 +58,11 @@ namespace Microsoft.Build.Internal.Expressions var ret = new ExpressionList (); while (start < end) { + int bak = start; ret.Add (ParseSingle (ref start, end)); SkipSpaces (ref start); + if (bak == start) + throw new Exception ("Parser failed to progress token position: " + source); } return ret; } @@ -122,7 +125,7 @@ namespace Microsoft.Build.Internal.Expressions int idx = source.IndexOfAny (token_starters, start + 1); string name = idx < 0 ? source.Substring (start, end - start) : source.Substring (start, idx - start); var val = new NameToken () { Name = name }; - ret = new StringLiteral () { Value = val }; + ret = new RawStringLiteral () { Value = val }; if (idx >= 0) start = idx; else -- 2.25.1