mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 21:48:11 +00:00
LibUnicode: Fix compilation when the UCD download is disabled
This commit is contained in:
parent
e8dbb1a8b2
commit
d382e77d38
2 changed files with 18 additions and 4 deletions
|
@ -432,7 +432,9 @@ if (BUILD_LAGOM)
|
||||||
# FIXME: LibLocaleData is an object lib in Lagom, because the weak symbol trick we use on serenity
|
# FIXME: LibLocaleData is an object lib in Lagom, because the weak symbol trick we use on serenity
|
||||||
# straight up isn't supposed to work per ELF rules
|
# straight up isn't supposed to work per ELF rules
|
||||||
target_link_libraries(LibLocale PRIVATE LibTimeZone)
|
target_link_libraries(LibLocale PRIVATE LibTimeZone)
|
||||||
install(TARGETS LibLocaleData EXPORT LagomTargets)
|
if (ENABLE_UNICODE_DATABASE_DOWNLOAD)
|
||||||
|
install(TARGETS LibLocaleData EXPORT LagomTargets)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_serenity_subdirectory(Userland/Shell)
|
add_serenity_subdirectory(Userland/Shell)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,12 @@
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
#include <LibUnicode/CharacterTypes.h>
|
#include <LibUnicode/CharacterTypes.h>
|
||||||
#include <LibUnicode/Normalize.h>
|
#include <LibUnicode/Normalize.h>
|
||||||
#include <LibUnicode/UnicodeData.h>
|
|
||||||
|
#if ENABLE_UNICODE_DATA
|
||||||
|
# include <LibUnicode/UnicodeData.h>
|
||||||
|
#else
|
||||||
|
struct Unicode::CodePointDecomposition { };
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Unicode {
|
namespace Unicode {
|
||||||
|
|
||||||
|
@ -118,9 +123,11 @@ static u32 combine_hangul_code_points(u32 a, u32 b)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 combine_code_points(u32 a, u32 b)
|
static u32 combine_code_points([[maybe_unused]] u32 a, [[maybe_unused]] u32 b)
|
||||||
{
|
{
|
||||||
|
#if ENABLE_UNICODE_DATA
|
||||||
Array<u32, 2> const points { a, b };
|
Array<u32, 2> const points { a, b };
|
||||||
|
|
||||||
// FIXME: Do something better than linear search to find reverse mappings.
|
// FIXME: Do something better than linear search to find reverse mappings.
|
||||||
for (size_t index = 0;; ++index) {
|
for (size_t index = 0;; ++index) {
|
||||||
auto mapping_maybe = Unicode::code_point_decomposition_by_index(index);
|
auto mapping_maybe = Unicode::code_point_decomposition_by_index(index);
|
||||||
|
@ -133,6 +140,8 @@ static u32 combine_code_points(u32 a, u32 b)
|
||||||
return mapping.code_point;
|
return mapping.code_point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,12 +150,14 @@ enum class UseCompatibility {
|
||||||
No
|
No
|
||||||
};
|
};
|
||||||
|
|
||||||
static void decompose_code_point(u32 code_point, Vector<u32>& code_points_output, UseCompatibility use_compatibility)
|
static void decompose_code_point(u32 code_point, Vector<u32>& code_points_output, [[maybe_unused]] UseCompatibility use_compatibility)
|
||||||
{
|
{
|
||||||
if (is_hangul_code_point(code_point)) {
|
if (is_hangul_code_point(code_point)) {
|
||||||
decompose_hangul_code_point(code_point, code_points_output);
|
decompose_hangul_code_point(code_point, code_points_output);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_UNICODE_DATA
|
||||||
auto const mapping = Unicode::code_point_decomposition(code_point);
|
auto const mapping = Unicode::code_point_decomposition(code_point);
|
||||||
if (mapping.has_value() && (mapping->tag == CompatibilityFormattingTag::Canonical || use_compatibility == UseCompatibility::Yes)) {
|
if (mapping.has_value() && (mapping->tag == CompatibilityFormattingTag::Canonical || use_compatibility == UseCompatibility::Yes)) {
|
||||||
for (auto code_point : mapping->decomposition) {
|
for (auto code_point : mapping->decomposition) {
|
||||||
|
@ -155,6 +166,7 @@ static void decompose_code_point(u32 code_point, Vector<u32>& code_points_output
|
||||||
} else {
|
} else {
|
||||||
code_points_output.append(code_point);
|
code_points_output.append(code_point);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can be any sorting algorithm that maintains order (like std::stable_sort),
|
// This can be any sorting algorithm that maintains order (like std::stable_sort),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue