Browse Source

Fixed error

tags/docs-0.9
RogueException 9 years ago
parent
commit
e64bed7bdb
1 changed files with 11 additions and 14 deletions
  1. +11
    -14
      src/Discord.Net.Commands/CommandParser.cs

+ 11
- 14
src/Discord.Net.Commands/CommandParser.cs View File

@@ -96,6 +96,7 @@ namespace Discord.Commands
else if (currentChar == '\\') else if (currentChar == '\\')
isEscaped = true; isEscaped = true;


bool isWhitespace = IsWhiteSpace(currentChar);
if (endPosition == startPosition + 1 && isWhitespace) //Has no text yet, and is another whitespace if (endPosition == startPosition + 1 && isWhitespace) //Has no text yet, and is another whitespace
{ {
startPosition = endPosition; startPosition = endPosition;
@@ -115,23 +116,19 @@ namespace Discord.Commands
currentPart = ParserPart.QuotedParameter; currentPart = ParserPart.QuotedParameter;
startPosition = endPosition; startPosition = endPosition;
} }
else
else if ((!isEscaped && isWhitespace) || endPosition >= inputLength)
{ {
bool isWhitespace = IsWhiteSpace(currentChar);
if ((!isEscaped && isWhitespace) || endPosition >= inputLength)
int length = (isWhitespace ? endPosition - 1 : endPosition) - startPosition;
string temp = input.Substring(startPosition, length);
if (temp == "")
startPosition = endPosition;
else
{ {
int length = (isWhitespace ? endPosition - 1 : endPosition) - startPosition;
string temp = input.Substring(startPosition, length);
if (temp == "")
startPosition = endPosition;
else
{
currentPart = ParserPart.None;
argList.Add(temp);
startPosition = endPosition;
}
currentPart = ParserPart.None;
argList.Add(temp);
startPosition = endPosition;
} }
}
}
break; break;
case ParserPart.QuotedParameter: case ParserPart.QuotedParameter:
if ((!isEscaped && currentChar == '\'')) if ((!isEscaped && currentChar == '\''))


Loading…
Cancel
Save