Fixed a couple parser errors

This commit is contained in:
RogueException
2016-01-01 19:42:09 -04:00
parent 72b24c1e42
commit 120950b539

View File

@@ -119,13 +119,13 @@ namespace Discord.Commands
else if ((!isEscaped && isWhitespace) || endPosition >= inputLength)
{
int length = (isWhitespace ? endPosition - 1 : endPosition) - startPosition;
string temp = input.Substring(startPosition, length);
if (temp == "")
if (length == 0)
startPosition = endPosition;
else
{
currentPart = ParserPart.None;
string temp = input.Substring(startPosition, length);
argList.Add(temp);
currentPart = ParserPart.None;
startPosition = endPosition;
}
}
@@ -134,8 +134,8 @@ namespace Discord.Commands
if ((!isEscaped && currentChar == '\''))
{
string temp = input.Substring(startPosition, endPosition - startPosition - 1);
currentPart = ParserPart.None;
argList.Add(temp);
currentPart = ParserPart.None;
startPosition = endPosition;
}
else if (endPosition >= inputLength)
@@ -145,8 +145,8 @@ namespace Discord.Commands
if ((!isEscaped && currentChar == '\"'))
{
string temp = input.Substring(startPosition, endPosition - startPosition - 1);
currentPart = ParserPart.None;
argList.Add(temp);
currentPart = ParserPart.None;
startPosition = endPosition;
}
else if (endPosition >= inputLength)
@@ -155,6 +155,11 @@ namespace Discord.Commands
}
}
//Unclosed quotes
if (currentPart == ParserPart.QuotedParameter ||
currentPart == ParserPart.DoubleQuotedParameter)
return CommandErrorType.InvalidInput;
//Too few args
for (int i = argList.Count; i < expectedArgs.Length; i++)
{