Skip to content

Fix #213: Fix a build error in the str_at instruction #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/engine/virtualmachine_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,14 @@ do_list_get_item : {

do_str_at : {
size_t index = READ_REG(1, 2)->toLong() - 1;
std::u16string str = READ_REG(0, 2)->toUtf16();
if (index < 0 || index >= str.size())
REPLACE_RET_VALUE("", 2);
else
REPLACE_RET_VALUE(utf8::utf16to8(std::u16string({ str[index] })), 2);
FREE_REGS(1);
{
std::u16string str = READ_REG(0, 2)->toUtf16();
if (index < 0 || index >= str.size())
REPLACE_RET_VALUE("", 2);
else
REPLACE_RET_VALUE(utf8::utf16to8(std::u16string({ str[index] })), 2);
FREE_REGS(1);
}
DISPATCH();
}

Expand Down