Skip to content

Commit

Permalink
Merge pull request #1440 from Mr-Rm/develop
Browse files Browse the repository at this point in the history
замена на системные функции
  • Loading branch information
EvilBeaver authored Aug 9, 2024
2 parents d95200d + 7c756d0 commit 0b24820
Showing 1 changed file with 4 additions and 29 deletions.
33 changes: 4 additions & 29 deletions src/ScriptEngine/Machine/MachineInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,40 +1554,15 @@ private void StrLen(int arg)

private void TrimL(int arg)
{
var str = _operationStack.Pop().AsString();

for (int i = 0; i < str.Length; i++)
{
if(!Char.IsWhiteSpace(str[i]))
{
var trimmed = str.Substring(i);
_operationStack.Push(ValueFactory.Create(trimmed));
NextInstruction();
return;
}
}

_operationStack.Push(ValueFactory.Create(""));
var str = _operationStack.Pop().AsString().TrimStart();
_operationStack.Push(ValueFactory.Create(str));
NextInstruction();
}

private void TrimR(int arg)
{
var str = _operationStack.Pop().AsString();

int lastIdx = str.Length-1;
for (int i = lastIdx; i >= 0; i--)
{
if (!Char.IsWhiteSpace(str[i]))
{
var trimmed = str.Substring(0, i+1);
_operationStack.Push(ValueFactory.Create(trimmed));
NextInstruction();
return;
}
}

_operationStack.Push(ValueFactory.Create(""));
var str = _operationStack.Pop().AsString().TrimEnd();
_operationStack.Push(ValueFactory.Create(str));
NextInstruction();
}

Expand Down

0 comments on commit 0b24820

Please sign in to comment.