mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 12:05:00 +00:00
LibRegex: Fix lookup table-based range checks in Compare
The lowercase version of a range is not required to be a valid range, instead of casefolding the range and making it invalid, check twice with both cases of the input character (which are the same as the input if not insensitive). This time includes an actual test :^)
This commit is contained in:
parent
b7c50f7094
commit
b85666b3d2
2 changed files with 7 additions and 7 deletions
|
@ -531,16 +531,15 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(MatchInput const& input, M
|
|||
auto ch = input.view.substring_view(state.string_position, 1)[0];
|
||||
|
||||
auto const* matching_range = binary_search(range_data, ch, nullptr, [insensitive = input.regex_options & AllFlags::Insensitive](auto needle, CharRange range) {
|
||||
auto from = range.from;
|
||||
auto to = range.to;
|
||||
auto upper_case_needle = needle;
|
||||
auto lower_case_needle = needle;
|
||||
if (insensitive) {
|
||||
from = to_ascii_lowercase(from);
|
||||
to = to_ascii_lowercase(to);
|
||||
needle = to_ascii_lowercase(needle);
|
||||
upper_case_needle = to_ascii_uppercase(needle);
|
||||
lower_case_needle = to_ascii_lowercase(needle);
|
||||
}
|
||||
if (needle > to)
|
||||
if (lower_case_needle > range.to && upper_case_needle > range.to)
|
||||
return 1;
|
||||
if (needle < from)
|
||||
if (lower_case_needle < range.from && upper_case_needle < range.from)
|
||||
return -1;
|
||||
return 0;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue