LibRegex: Fix reported compare-against value in debug

This commit is contained in:
AnotherTest 2020-11-27 17:26:45 +03:30 committed by Andreas Kling
parent dbef2b1ee9
commit 75081b2bdd
Notes: sideshowbarker 2024-07-19 01:14:36 +09:00

View file

@ -704,7 +704,7 @@ const Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<Match
char ch = m_bytecode->at(offset++);
result.empend(String::format("value='%c'", ch));
if (!view.is_null())
result.empend(String::format("compare against: '%s'", view.substring_view(state().string_position, state().string_position + 1 > view.length() ? 0 : 1).to_string().characters()));
result.empend(String::format("compare against: '%s'", view.substring_view(state().string_position - 1, state().string_position > view.length() ? 0 : 1).to_string().characters()));
} else if (compare_type == CharacterCompareType::NamedReference) {
auto ptr = (const char*)m_bytecode->at(offset++);
auto length = m_bytecode->at(offset++);
@ -717,17 +717,17 @@ const Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<Match
auto& length = m_bytecode->at(offset++);
result.empend(String::format("value=\"%.*s\"", length, str));
if (!view.is_null())
result.empend(String::format("compare against: \"%s\"", input.value().view.substring_view(state().string_position, state().string_position + length > view.length() ? 0 : length).to_string().characters()));
result.empend(String::format("compare against: \"%s\"", input.value().view.substring_view(state().string_position - 1, state().string_position + length - 1 > view.length() ? 0 : length).to_string().characters()));
} else if (compare_type == CharacterCompareType::CharClass) {
auto character_class = (CharClass)m_bytecode->at(offset++);
result.empend(String::format("ch_class=%lu [%s]", (size_t)character_class, character_class_name(character_class)));
if (!view.is_null())
result.empend(String::format("compare against: '%s'", input.value().view.substring_view(state().string_position, state().string_position + 1 > view.length() ? 0 : 1).to_string().characters()));
result.empend(String::format("compare against: '%s'", input.value().view.substring_view(state().string_position - 1, state().string_position > view.length() ? 0 : 1).to_string().characters()));
} else if (compare_type == CharacterCompareType::CharRange) {
auto value = (CharRange)m_bytecode->at(offset++);
result.empend(String::format("ch_range='%c'-'%c'", value.from, value.to));
if (!view.is_null())
result.empend(String::format("compare against: '%s'", input.value().view.substring_view(state().string_position, state().string_position + 1 > view.length() ? 0 : 1).to_string().characters()));
result.empend(String::format("compare against: '%s'", input.value().view.substring_view(state().string_position - 1, state().string_position > view.length() ? 0 : 1).to_string().characters()));
}
}
return result;