diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -33,4 +33,23 @@ static double util_mind(double a, double b) { return a < b ? a : b; } +// for finding a character in a char32 string +static char32_t *util_mem32chr(char32_t *s, char32_t c, size_t n) { + for (size_t i = 0; i < n; ++i) { + if (s[i] == c) { + return &s[i]; + } + } + return NULL; +} + +static char32_t const *util_mem32chr_const(char32_t const *s, char32_t c, size_t n) { + for (size_t i = 0; i < n; ++i) { + if (s[i] == c) { + return &s[i]; + } + } + return NULL; +} + #endif |