Browse Source

Fix command parser not using methods with `Text` output

pull/8/head
Anton Tarasenko 2 years ago
parent
commit
caa2d01a7e
  1. 17
      sources/Commands/CommandParser.uc

17
sources/Commands/CommandParser.uc

@ -544,28 +544,29 @@ private final function bool ParseTextValue(
Command.Parameter expectedParameter) Command.Parameter expectedParameter)
{ {
local bool failedParsing; local bool failedParsing;
local string textValue; local MutableText textValue;
local parser.ParserState initialState; local Parser.ParserState initialState;
// TODO: use parsing methods into `Text`
// (needs some work for reading formatting `string`s from `Text` objects) // (needs some work for reading formatting `string`s from `Text` objects)
initialState = commandParser.Skip().GetCurrentState(); initialState = commandParser.Skip().GetCurrentState();
// Try manually parsing as a string literal first, since then we will // Try manually parsing as a string literal first, since then we will
// allow empty `textValue` as a result // allow empty `textValue` as a result
commandParser.MStringLiteralS(textValue); commandParser.MStringLiteral(textValue);
failedParsing = !commandParser.Ok(); failedParsing = !commandParser.Ok();
// Otherwise - empty values are not allowed // Otherwise - empty values are not allowed
if (failedParsing) if (failedParsing)
{ {
commandParser.RestoreState(initialState).MStringS(textValue); _.memory.Free(textValue);
failedParsing = (!commandParser.Ok() || textValue == ""); commandParser.RestoreState(initialState).MString(textValue);
failedParsing = (!commandParser.Ok() || textValue.IsEmpty());
} }
if (failedParsing) if (failedParsing)
{ {
_.memory.Free(textValue);
commandParser.Fail(); commandParser.Fail();
return false; return false;
} }
RecordParameter(parsedParameters, expectedParameter, RecordParameter(parsedParameters, expectedParameter, textValue.IntoText());
_.text.FromString(textValue));
return true; return true;
} }

Loading…
Cancel
Save