diff options
| author | Mattias Andrée <m@maandree.se> | 2025-12-21 09:53:48 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2025-12-21 09:53:48 +0100 |
| commit | 15904ad51325426bcb3b8e87e714584e437417b7 (patch) | |
| tree | ef41e227769654a5b28b6e55d040200313cc57ea /libcmap_find_in_no_block.c | |
| parent | First commit (diff) | |
| download | libcmap-15904ad51325426bcb3b8e87e714584e437417b7.tar.gz libcmap-15904ad51325426bcb3b8e87e714584e437417b7.tar.bz2 libcmap-15904ad51325426bcb3b8e87e714584e437417b7.tar.xz | |
Implement script and block listing
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libcmap_find_in_no_block.c')
| -rw-r--r-- | libcmap_find_in_no_block.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libcmap_find_in_no_block.c b/libcmap_find_in_no_block.c new file mode 100644 index 0000000..216aaa0 --- /dev/null +++ b/libcmap_find_in_no_block.c @@ -0,0 +1,20 @@ +/* See LICENSE file for copyright and license details. */ +#include "libcmap.h" + + +int +libcmap_find_in_no_block(uint32_t codepoint, size_t *offset_out, size_t *subrange_out) +{ + size_t i, skipped = 0; + for (i = 0; i < libcmap_no_block.nranges; i++) { + if (libcmap_no_block.ranges[i].first <= codepoint && libcmap_no_block.ranges[i].last <= codepoint) { + if (offset_out) + *offset_out = skipped + (size_t)(codepoint - libcmap_no_block.ranges[i].first); + if (subrange_out) + *subrange_out = i; + return 1; + } + skipped += (size_t)(libcmap_no_block.ranges[i].last - libcmap_no_block.ranges[i].first) + 1U; + } + return 0; +} |
