From 36087e77db73f39734d38e41cd9856382cf3ea4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1ximo=20Casta=C3=B1eda?= Date: Tue, 2 Jul 2024 17:08:58 +0200 Subject: [PATCH] CharacterMap: fix block filter Some of the Unicode blocks correspond to the union of two blocks as defined in BeOS (for example, "Arabic" includes B_BASIC_ARABIC_BLOCK and B_ARABIC_EXTENDED_BLOCK), making the `Includes` test inadequate. Change-Id: Ib1a358f6be8a8f517c6b8a3642536b3e75d365a4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7828 Haiku-Format: Haiku-format Bot Tested-by: Commit checker robot Reviewed-by: Adrien Destugues --- src/apps/charactermap/CharacterView.cpp | 12 +++++------- src/apps/charactermap/UnicodeBlockView.cpp | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/apps/charactermap/CharacterView.cpp b/src/apps/charactermap/CharacterView.cpp index 4114fb2195..49e6da6853 100644 --- a/src/apps/charactermap/CharacterView.cpp +++ b/src/apps/charactermap/CharacterView.cpp @@ -97,17 +97,15 @@ CharacterView::IsShowingBlock(int32 blockIndex) const if (!fShowPrivateBlocks && kUnicodeBlocks[blockIndex].private_block) return false; - // the reason for two checks is BeOS compatibility. - // The Includes method checks for unicode blocks as - // defined by Be, but there are only 71 such blocks. + // The reason for two checks is BeOS compatibility. + // The first one checks for unicode blocks as defined by Be, + // but there are only 71 such blocks. // The rest of the blocks (denoted by kNoBlock) need to // be queried by searching for the start and end codepoints // via the IncludesBlock method. if (fShowContainedBlocksOnly) { - if (kUnicodeBlocks[blockIndex].block != kNoBlock - && !fUnicodeBlocks.Includes( - kUnicodeBlocks[blockIndex].block)) - return false; + if (kUnicodeBlocks[blockIndex].block != kNoBlock) + return (fUnicodeBlocks & kUnicodeBlocks[blockIndex].block) != kNoBlock; if (!fCharacterFont.IncludesBlock( kUnicodeBlocks[blockIndex].start, diff --git a/src/apps/charactermap/UnicodeBlockView.cpp b/src/apps/charactermap/UnicodeBlockView.cpp index 461e261fb8..07217a4762 100644 --- a/src/apps/charactermap/UnicodeBlockView.cpp +++ b/src/apps/charactermap/UnicodeBlockView.cpp @@ -84,17 +84,15 @@ UnicodeBlockView::IsShowingBlock(int32 blockIndex) const if (!fShowPrivateBlocks && kUnicodeBlocks[blockIndex].private_block) return false; - // the reason for two checks is BeOS compatibility. - // The Includes method checks for unicode blocks as - // defined by Be, but there are only 71 such blocks. + // The reason for two checks is BeOS compatibility. + // The first one checks for unicode blocks as defined by Be, + // but there are only 71 such blocks. // The rest of the blocks (denoted by kNoBlock) need to // be queried by searching for the start and end codepoints // via the IncludesBlock method. if (fShowContainedBlocksOnly) { - if (kUnicodeBlocks[blockIndex].block != kNoBlock - && !fUnicodeBlocks.Includes( - kUnicodeBlocks[blockIndex].block)) - return false; + if (kUnicodeBlocks[blockIndex].block != kNoBlock) + return (fUnicodeBlocks & kUnicodeBlocks[blockIndex].block) != kNoBlock; if (!fCharacterFont.IncludesBlock( kUnicodeBlocks[blockIndex].start,