diff options
Diffstat (limited to 'include/unicode')
-rw-r--r-- | include/unicode/string.h | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/include/unicode/string.h b/include/unicode/string.h index 7d62171..077a45a 100644 --- a/include/unicode/string.h +++ b/include/unicode/string.h @@ -3,22 +3,22 @@ #include <stddef.h> -#include "_alloc_fn.h" +#include "_allocator.h" #include "_charN_t.h" #include "_uNview.h" /* clang-format off */ -enum [[clang::flag_enum]] caseflags { +typedef enum [[clang::flag_enum]] { CF_LANG_AZ = 1 << 0, /* Azeri; alias for CF_LANG_TR */ CF_LANG_TR = 1 << 0, /* Turkish; alias for CF_LANG_AZ */ CF_LANG_LT = 1 << 1, /* Lithuanian */ CF_LANG_NL = 1 << 2, /* Dutch */ CF_SS = 1 << 3, /* Use ‘ẞ’ as the uppercase of ‘ß’; alias for CF_ẞ */ CF_ẞ = 1 << 3, /* Use ‘ẞ’ as the uppercase of ‘ß’; alias for CF_SS */ -}; +} caseflags_t; -enum normform { +typedef enum { /* If bit 0 is set, then composition is performed after decomposition. If bit-1 is set then compatibility (de)composition is used as opposed to canonical (de)composition. */ @@ -26,7 +26,7 @@ enum normform { NF_NFC = 0b01, NF_NFKD = 0b10, NF_NFKC = 0b11, -}; +} normform_t; /* clang-format on */ @@ -37,16 +37,11 @@ enum normform { size_t u8gnext(u8view_t *, u8view_t *); size_t u8wnext(u8view_t *, u8view_t *); size_t u8wnext_human(u8view_t *, u8view_t *); -[[nodiscard]] char8_t *u8casefold(size_t *, u8view_t, enum caseflags, - alloc_fn, void *); -[[nodiscard]] char8_t *u8lower(size_t *, u8view_t, enum caseflags, - alloc_fn, void *); -[[nodiscard]] char8_t *u8title(size_t *, u8view_t, enum caseflags, - alloc_fn, void *); -[[nodiscard]] char8_t *u8upper(size_t *, u8view_t, enum caseflags, - alloc_fn, void *); -[[nodiscard]] char8_t *u8norm(size_t *, u8view_t, alloc_fn, void *, - enum normform); +[[nodiscard]] char8_t *u8casefold(size_t *, u8view_t, caseflags_t, allocator_t); +[[nodiscard]] char8_t *u8lower(size_t *, u8view_t, caseflags_t, allocator_t); +[[nodiscard]] char8_t *u8title(size_t *, u8view_t, caseflags_t, allocator_t); +[[nodiscard]] char8_t *u8upper(size_t *, u8view_t, caseflags_t, allocator_t); +[[nodiscard]] char8_t *u8norm(size_t *, u8view_t, allocator_t, normform_t); /* Encoding-generic macros */ #define ucswdth(sv, ts) _Generic((sv), u8view_t: u8wdth)((sv), (ts)) @@ -55,22 +50,18 @@ size_t u8wnext_human(u8view_t *, u8view_t *); #define ucswcnt_human(sv) _Generic((sv), u8view_t: u8wcnt_human)((sv)) #define ucsgnext(g, sv) _Generic((sv), u8view_t *: u8gnext)((g), (sv)) #define ucswnext(g, sv) _Generic((sv), u8view_t *: u8wnext)((g), (sv)) -#define ucswnext_human(g, sv) \ +#define ucswnext_human(g, sv) \ _Generic((sv), u8view_t *: u8wnext_human)((g), (sv)) -#define ucscasefold(dstn, sv, flags, alloc, ctx) \ - _Generic((sv), u8view_t: u8casefold)((dstn), (sv), (flags), (alloc), \ - (ctx)) -#define ucslower(dstn, sv, flags, alloc, ctx) \ - _Generic((sv), u8view_t: u8lower)((dstn), (sv), (flags), (alloc), \ - (ctx)) -#define ucstitle(dstn, sv, flags, alloc, ctx) \ - _Generic((sv), u8view_t: u8title)((dstn), (sv), (flags), (alloc), \ - (ctx)) -#define ucsupper(dstn, sv, flags, alloc, ctx) \ - _Generic((sv), u8view_t: u8upper)((dstn), (sv), (flags), (alloc), \ - (ctx)) -#define ucsnorm(dstn, sv, alloc, ctx, nf) \ - _Generic((sv), u8view_t: u8norm)((dstn), (sv), (alloc), (ctx), (nf)) +#define ucscasefold(dstn, sv, flags, mem) \ + _Generic((sv), u8view_t: u8casefold)((dstn), (sv), (flags), (mem)) +#define ucslower(dstn, sv, flags, mem) \ + _Generic((sv), u8view_t: u8lower)((dstn), (sv), (flags), (mem)) +#define ucstitle(dstn, sv, flags, mem) \ + _Generic((sv), u8view_t: u8title)((dstn), (sv), (flags), (mem)) +#define ucsupper(dstn, sv, flags, mem) \ + _Generic((sv), u8view_t: u8upper)((dstn), (sv), (flags), (mem)) +#define ucsnorm(dstn, sv, mem, nf) \ + _Generic((sv), u8view_t: u8norm)((dstn), (sv), (mem), (nf)) constexpr double U8CASEFOLD_SCALE = 3; constexpr double U8LOWER_SCALE = 1.5; |