Skip to content

Commit

Permalink
Meta+Userland: Fix more instances of bad lambda-Variant interaction
Browse files Browse the repository at this point in the history
These don't cause compilation to fail but they still crash crashd.
  • Loading branch information
DanShaders authored and ADKaster committed Apr 18, 2024
1 parent d282066 commit b8c3e75
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
60 changes: 31 additions & 29 deletions Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,42 +1724,44 @@ struct PropertyMetadata {
// this process reduces over 1 million entries (0x10ffff) to ~44,030.
//
// For much more in-depth reading, see: https://icu.unicode.org/design/struct/utrie
static ErrorOr<void> create_code_point_tables(UnicodeData& unicode_data)
static constexpr auto MAX_CODE_POINT = 0x10ffffu;

template<typename T>
static ErrorOr<void> update_tables(u32 code_point, CodePointTables<T>& tables, auto& metadata, auto const& values)
{
static constexpr auto MAX_CODE_POINT = 0x10ffffu;
static constexpr auto BLOCK_SIZE = CODE_POINT_TABLES_LSB_MASK + 1;

size_t unique_properties_index = 0;
if (auto block_index = tables.unique_properties.find_first_index(values); block_index.has_value()) {
unique_properties_index = *block_index;
} else {
unique_properties_index = tables.unique_properties.size();
TRY(tables.unique_properties.try_append(values));
}

auto update_tables = [&](auto code_point, auto& tables, auto& metadata, auto const& values) -> ErrorOr<void> {
static constexpr auto BLOCK_SIZE = CODE_POINT_TABLES_LSB_MASK + 1;
TRY(metadata.current_block.try_append(unique_properties_index));

size_t unique_properties_index = 0;
if (auto block_index = tables.unique_properties.find_first_index(values); block_index.has_value()) {
unique_properties_index = *block_index;
if (metadata.current_block.size() == BLOCK_SIZE || code_point == MAX_CODE_POINT) {
size_t stage2_index = 0;
if (auto block_index = metadata.unique_blocks.get(metadata.current_block); block_index.has_value()) {
stage2_index = *block_index;
} else {
unique_properties_index = tables.unique_properties.size();
TRY(tables.unique_properties.try_append(values));
}

TRY(metadata.current_block.try_append(unique_properties_index));

if (metadata.current_block.size() == BLOCK_SIZE || code_point == MAX_CODE_POINT) {
size_t stage2_index = 0;
if (auto block_index = metadata.unique_blocks.get(metadata.current_block); block_index.has_value()) {
stage2_index = *block_index;
} else {
stage2_index = tables.stage2.size();
TRY(tables.stage2.try_extend(metadata.current_block));

TRY(metadata.unique_blocks.try_set(metadata.current_block, stage2_index));
}
stage2_index = tables.stage2.size();
TRY(tables.stage2.try_extend(metadata.current_block));

TRY(tables.stage1.try_append(stage2_index));
metadata.current_block.clear_with_capacity();
TRY(metadata.unique_blocks.try_set(metadata.current_block, stage2_index));
}

return {};
};
TRY(tables.stage1.try_append(stage2_index));
metadata.current_block.clear_with_capacity();
}

return {};
}

auto update_casing_tables = [&](auto code_point, auto& tables, auto& metadata) -> ErrorOr<void> {
static ErrorOr<void> create_code_point_tables(UnicodeData& unicode_data)
{
auto update_casing_tables = [&]<typename T>(u32 code_point, CodePointTables<T>& tables, CasingMetadata& metadata) -> ErrorOr<void> {
CasingTable casing {};

while (metadata.iterator != metadata.end) {
Expand All @@ -1778,7 +1780,7 @@ static ErrorOr<void> create_code_point_tables(UnicodeData& unicode_data)
return {};
};

auto update_property_tables = [&](auto code_point, auto& tables, auto& metadata) -> ErrorOr<void> {
auto update_property_tables = [&]<typename T>(u32 code_point, CodePointTables<T>& tables, PropertyMetadata& metadata) -> ErrorOr<void> {
static Unicode::CodePointRangeComparator comparator {};

for (auto& property_values : metadata.property_values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ErrorOr<RefPtr<GUI::Widget>> HueAndSaturation::get_settings_widget()
auto settings_widget = GUI::Widget::construct();
settings_widget->set_layout<GUI::VerticalBoxLayout>();

auto add_slider = [&](auto name, int min, int max, auto member) -> ErrorOr<void> {
auto add_slider = [&](StringView name, int min, int max, auto member) -> ErrorOr<void> {
auto& name_label = settings_widget->add<GUI::Label>(TRY(String::from_utf8(name)));
name_label.set_font_weight(Gfx::FontWeight::Bold);
name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
Expand Down
2 changes: 1 addition & 1 deletion Userland/Shell/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ ErrorOr<RefPtr<Job>> Shell::run_command(const AST::Command& command)

// Resolve redirections.
Vector<NonnullRefPtr<AST::Rewiring>> rewirings;
auto resolve_redirection = [&](auto& redirection) -> ErrorOr<void> {
auto resolve_redirection = [&](NonnullRefPtr<AST::Redirection> const& redirection) -> ErrorOr<void> {
auto rewiring = TRY(redirection->apply());

if (rewiring->fd_action != AST::Rewiring::Close::ImmediatelyCloseNew)
Expand Down

0 comments on commit b8c3e75

Please sign in to comment.