Skip to content

Commit

Permalink
Merge pull request #223 from ItEndsWithTens/feature/fix-condition-neg…
Browse files Browse the repository at this point in the history
…ative-literals

Allow negative literals in conditions
  • Loading branch information
mhutch authored May 3, 2024
2 parents 8abab26 + e89a35d commit f0d663d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions MonoDevelop.MSBuild.Tests/MSBuildConditionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public void TestParenGrouping ()
[TestCase ("'$(foo)' == '' and ('$(bar)' == '')")] // paren group at end of expression string
[TestCase ("")] // empty expression
[TestCase (" ")] // whitespace only
[TestCase ("'$(foo)' > 1.0")] // decimal literal
[TestCase ("'$(foo)' > -1.0")] // negative decimal literal
public void TestParseNoError (string expressionString)
{
var expression = ExpressionParser.ParseCondition (expressionString, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static ExpressionNode ParseConditionOperand (string buffer, ref int offset, int
int start = offset;

var ch = buffer[start];
if (ch == '.' || char.IsDigit (ch)) {
if (ch == '-' || ch == '.' || char.IsDigit (ch)) {
return ReadArgumentNumber (buffer, ref offset, endOffset, baseOffset, out hasError);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ static ExpressionNode ReadArgumentNumber (string buffer, ref int offset, int end
goto case '0';
case ',': case ')': case ']': case ' ': case '\r': case '\n': case '\t':
return Result (ref offset, out hasError);
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
case '-': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
offset++;
continue;
default:
Expand Down

0 comments on commit f0d663d

Please sign in to comment.