From caa2d01a7e11d3c709ede3c5d923cbe048230f1d Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 3 Oct 2022 04:13:30 +0700 Subject: [PATCH] Fix command parser not using methods with `Text` output --- sources/Commands/CommandParser.uc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sources/Commands/CommandParser.uc b/sources/Commands/CommandParser.uc index a3a03ba..66d5c3d 100644 --- a/sources/Commands/CommandParser.uc +++ b/sources/Commands/CommandParser.uc @@ -544,28 +544,29 @@ private final function bool ParseTextValue( Command.Parameter expectedParameter) { local bool failedParsing; - local string textValue; - local parser.ParserState initialState; - // TODO: use parsing methods into `Text` + local MutableText textValue; + local Parser.ParserState initialState; + // (needs some work for reading formatting `string`s from `Text` objects) initialState = commandParser.Skip().GetCurrentState(); // Try manually parsing as a string literal first, since then we will // allow empty `textValue` as a result - commandParser.MStringLiteralS(textValue); + commandParser.MStringLiteral(textValue); failedParsing = !commandParser.Ok(); // Otherwise - empty values are not allowed if (failedParsing) { - commandParser.RestoreState(initialState).MStringS(textValue); - failedParsing = (!commandParser.Ok() || textValue == ""); + _.memory.Free(textValue); + commandParser.RestoreState(initialState).MString(textValue); + failedParsing = (!commandParser.Ok() || textValue.IsEmpty()); } if (failedParsing) { + _.memory.Free(textValue); commandParser.Fail(); return false; } - RecordParameter(parsedParameters, expectedParameter, - _.text.FromString(textValue)); + RecordParameter(parsedParameters, expectedParameter, textValue.IntoText()); return true; }