mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 23:39:02 +00:00
LibRegex: Partially implement string compare for Utf32View
This commit is contained in:
parent
da1fda73a7
commit
052004f92d
Notes:
sideshowbarker
2024-07-18 08:47:49 +09:00
Author: https://github.com/alimpfard
Commit: 052004f92d
Pull-request: https://github.com/SerenityOS/serenity/pull/8847
Reviewed-by: https://github.com/MaxWipfli
Reviewed-by: https://github.com/linusg ✅
Reviewed-by: https://github.com/trflynn89
1 changed files with 16 additions and 2 deletions
|
@ -529,6 +529,11 @@ ALWAYS_INLINE void OpCode_Compare::compare_char(const MatchInput& input, MatchSt
|
||||||
|
|
||||||
ALWAYS_INLINE bool OpCode_Compare::compare_string(const MatchInput& input, MatchState& state, const char* str, size_t length, bool& had_zero_length_match)
|
ALWAYS_INLINE bool OpCode_Compare::compare_string(const MatchInput& input, MatchState& state, const char* str, size_t length, bool& had_zero_length_match)
|
||||||
{
|
{
|
||||||
|
if (length == 0) {
|
||||||
|
had_zero_length_match = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (input.view.is_u8_view()) {
|
if (input.view.is_u8_view()) {
|
||||||
auto str_view1 = StringView(str, length);
|
auto str_view1 = StringView(str, length);
|
||||||
auto str_view2 = StringView(&input.view.u8view()[state.string_position], length);
|
auto str_view2 = StringView(&input.view.u8view()[state.string_position], length);
|
||||||
|
@ -541,8 +546,17 @@ ALWAYS_INLINE bool OpCode_Compare::compare_string(const MatchInput& input, Match
|
||||||
|
|
||||||
if (string_equals) {
|
if (string_equals) {
|
||||||
state.string_position += length;
|
state.string_position += length;
|
||||||
if (length == 0)
|
return true;
|
||||||
had_zero_length_match = true;
|
}
|
||||||
|
} else {
|
||||||
|
bool equals;
|
||||||
|
if (input.regex_options & AllFlags::Insensitive)
|
||||||
|
TODO();
|
||||||
|
else
|
||||||
|
equals = __builtin_memcmp(str, &input.view.u32view().code_points()[state.string_position], length) == 0;
|
||||||
|
|
||||||
|
if (equals) {
|
||||||
|
state.string_position += length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue