From 450fd004b8f8358dc46e1bcc1bceae821f7ae158 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 5 Apr 2024 14:26:33 +0200 Subject: Add boolean properties to unicode/prop.h --- lib/unicode/prop/uprop_is_hex.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/unicode/prop/uprop_is_hex.c (limited to 'lib/unicode/prop/uprop_is_hex.c') diff --git a/lib/unicode/prop/uprop_is_hex.c b/lib/unicode/prop/uprop_is_hex.c new file mode 100644 index 0000000..c2e6793 --- /dev/null +++ b/lib/unicode/prop/uprop_is_hex.c @@ -0,0 +1,31 @@ +/* This file is autogenerated by gen/prop/bool-props; DO NOT EDIT. */ + +#include "__bsearch.h" +#include "bitset.h" +#include "rune.h" +#include "unicode/prop.h" + +/* clang-format off */ + +static constexpr bitset(bs, LATIN1_MAX) = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x03, + 0x7E, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const struct { + rune lo, hi; +} lookup[] = { + {RUNE_C(0x00FF10), RUNE_C(0x00FF19)}, + {RUNE_C(0x00FF21), RUNE_C(0x00FF26)}, + {RUNE_C(0x00FF41), RUNE_C(0x00FF46)}, +}; + +__MLIB_DEFINE_BSEARCH_CONTAINS(lookup) + +bool +uprop_is_hex(rune ch) +{ + return ch <= LATIN1_MAX ? TESTBIT(bs, ch) : mlib_lookup_contains(ch); +} -- cgit v1.2.3