mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +00:00
LibRegex: Support property escapes of Unicode script extensions
This commit is contained in:
parent
5edd458420
commit
484ccfadc3
5 changed files with 51 additions and 7 deletions
|
@ -573,6 +573,10 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M
|
|||
auto script = static_cast<Unicode::Script>(m_bytecode->at(offset++));
|
||||
compare_script(input, state, script, current_inversion_state(), inverse_matched);
|
||||
|
||||
} else if (compare_type == CharacterCompareType::ScriptExtension) {
|
||||
auto script = static_cast<Unicode::Script>(m_bytecode->at(offset++));
|
||||
compare_script_extension(input, state, script, current_inversion_state(), inverse_matched);
|
||||
|
||||
} else {
|
||||
warnln("Undefined comparison: {}", (int)compare_type);
|
||||
VERIFY_NOT_REACHED();
|
||||
|
@ -810,6 +814,22 @@ ALWAYS_INLINE void OpCode_Compare::compare_script(MatchInput const& input, Match
|
|||
}
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void OpCode_Compare::compare_script_extension(MatchInput const& input, MatchState& state, Unicode::Script script, bool inverse, bool& inverse_matched)
|
||||
{
|
||||
if (state.string_position == input.view.length())
|
||||
return;
|
||||
|
||||
u32 code_point = input.view[state.string_position_in_code_units];
|
||||
bool equal = Unicode::code_point_has_script_extension(code_point, script);
|
||||
|
||||
if (equal) {
|
||||
if (inverse)
|
||||
inverse_matched = true;
|
||||
else
|
||||
advance_string_position(state, input.view, code_point);
|
||||
}
|
||||
}
|
||||
|
||||
String const OpCode_Compare::arguments_string() const
|
||||
{
|
||||
return String::formatted("argc={}, args={} ", arguments_count(), arguments_size());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue