From 03f69018340f0fae95556321a3d89dcb49910ebe Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 5 Apr 2024 15:35:58 +0200 Subject: Add more predicates to unicode/prop.h --- lib/unicode/prop/uprop_is_idst.c | 7 +++++++ lib/unicode/prop/uprop_is_idsu.c | 7 +++++++ lib/unicode/prop/uprop_is_join_c.c | 7 +++++++ lib/unicode/prop/uprop_is_nchar.c | 10 ++++++++++ lib/unicode/prop/uprop_is_pat_ws.c | 30 ++++++++++++++++++++++++++++++ lib/unicode/prop/uprop_is_ri.c | 8 ++++++++ 6 files changed, 69 insertions(+) create mode 100644 lib/unicode/prop/uprop_is_idst.c create mode 100644 lib/unicode/prop/uprop_is_idsu.c create mode 100644 lib/unicode/prop/uprop_is_join_c.c create mode 100644 lib/unicode/prop/uprop_is_nchar.c create mode 100644 lib/unicode/prop/uprop_is_pat_ws.c create mode 100644 lib/unicode/prop/uprop_is_ri.c (limited to 'lib/unicode/prop') diff --git a/lib/unicode/prop/uprop_is_idst.c b/lib/unicode/prop/uprop_is_idst.c new file mode 100644 index 0000000..b303838 --- /dev/null +++ b/lib/unicode/prop/uprop_is_idst.c @@ -0,0 +1,7 @@ +#include "unicode/prop.h" + +bool +uprop_is_idst(rune ch) +{ + return ch == 0x2FF2 || ch == 0x2FF3; +} diff --git a/lib/unicode/prop/uprop_is_idsu.c b/lib/unicode/prop/uprop_is_idsu.c new file mode 100644 index 0000000..66bc3c6 --- /dev/null +++ b/lib/unicode/prop/uprop_is_idsu.c @@ -0,0 +1,7 @@ +#include "unicode/prop.h" + +bool +uprop_is_idsu(rune ch) +{ + return ch == 0x2FFE || ch == 0x2FFF; +} diff --git a/lib/unicode/prop/uprop_is_join_c.c b/lib/unicode/prop/uprop_is_join_c.c new file mode 100644 index 0000000..91dd816 --- /dev/null +++ b/lib/unicode/prop/uprop_is_join_c.c @@ -0,0 +1,7 @@ +#include "unicode/prop.h" + +bool +uprop_is_join_c(rune ch) +{ + return ch == 0x200C || ch == 0x200D; +} diff --git a/lib/unicode/prop/uprop_is_nchar.c b/lib/unicode/prop/uprop_is_nchar.c new file mode 100644 index 0000000..7022d2e --- /dev/null +++ b/lib/unicode/prop/uprop_is_nchar.c @@ -0,0 +1,10 @@ +#include "rune.h" +#include "unicode/prop.h" + +bool +rprop_is_nchar(rune ch) +{ + return (ch >= 0xFDD0 && ch <= 0xFDEF) + || ((ch & 0xFFFE) == 0xFFFE + && (ch & RUNE_C(0xFF0000)) <= RUNE_C(0x0F0000)); +} diff --git a/lib/unicode/prop/uprop_is_pat_ws.c b/lib/unicode/prop/uprop_is_pat_ws.c new file mode 100644 index 0000000..fe2f462 --- /dev/null +++ b/lib/unicode/prop/uprop_is_pat_ws.c @@ -0,0 +1,30 @@ +/* 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, 0x3E, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +}; + +static const struct { + rune lo, hi; +} lookup[] = { + {RUNE_C(0x00200E), RUNE_C(0x00200F)}, + {RUNE_C(0x002028), RUNE_C(0x002029)}, +}; + +__MLIB_DEFINE_BSEARCH_CONTAINS(lookup) + +bool +uprop_is_pat_ws(rune ch) +{ + return ch <= LATIN1_MAX ? TESTBIT(bs, ch) : mlib_lookup_contains(ch); +} diff --git a/lib/unicode/prop/uprop_is_ri.c b/lib/unicode/prop/uprop_is_ri.c new file mode 100644 index 0000000..4ce6a75 --- /dev/null +++ b/lib/unicode/prop/uprop_is_ri.c @@ -0,0 +1,8 @@ +#include "rune.h" +#include "unicode/prop.h" + +bool +uprop_is_ri(rune ch) +{ + return ch >= RUNE_C(0x1F1E6) && ch <= RUNE_C(0x1F1FF); +} -- cgit v1.2.3