From 43e9dc0500b9d8277a2c9ee7e99d9c41c1c18509 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Sun, 10 Dec 2023 09:06:21 -0500 Subject: [PATCH] LibUnicode: Use weak symbols to provide default IDNA defintions Rather than using #ifdef blocks, update the fallback IDNA definitions to use weak symbols to match the rest of LibUnicode / LibLocale. --- .../CodeGenerators/LibUnicode/GenerateIDNAData.cpp | 11 +++-------- Userland/Libraries/LibUnicode/IDNA.cpp | 9 +-------- Userland/Libraries/LibUnicode/IDNA.h | 1 + 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateIDNAData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateIDNAData.cpp index 11da74ca78..9fee7fec10 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateIDNAData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateIDNAData.cpp @@ -106,13 +106,7 @@ static ErrorOr generate_idna_data_header(Core::InputBufferedFile& file, ID generator.append(R"~~~( #pragma once -#include -#include - namespace Unicode::IDNA { - -Optional get_idna_mapping(u32 code_point); - } )~~~"); @@ -128,11 +122,12 @@ static ErrorOr generate_idna_data_implementation(Core::InputBufferedFile& generator.set("idna_table_size", TRY(String::number(idna_data.mapping_table.size()))); generator.append(R"~~~( - #include +#include #include -#include #include +#include +#include namespace Unicode::IDNA { diff --git a/Userland/Libraries/LibUnicode/IDNA.cpp b/Userland/Libraries/LibUnicode/IDNA.cpp index 8c2b2e84fc..7eb1e22ba0 100644 --- a/Userland/Libraries/LibUnicode/IDNA.cpp +++ b/Userland/Libraries/LibUnicode/IDNA.cpp @@ -18,14 +18,7 @@ namespace Unicode::IDNA { -#if not ENABLE_UNICODE_DATA - -Optional get_idna_mapping(u32) -{ - return {}; -} - -#endif +Optional __attribute__((weak)) get_idna_mapping(u32) { return {}; } struct ProcessingResult { Vector result {}; diff --git a/Userland/Libraries/LibUnicode/IDNA.h b/Userland/Libraries/LibUnicode/IDNA.h index 294f1bc9e7..cf62004288 100644 --- a/Userland/Libraries/LibUnicode/IDNA.h +++ b/Userland/Libraries/LibUnicode/IDNA.h @@ -73,5 +73,6 @@ struct ToAsciiOptions { }; ErrorOr to_ascii(Utf8View domain_name, ToAsciiOptions const& = {}); +Optional get_idna_mapping(u32 code_point); }