summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/util.c b/util.c
index e183461..09da480 100644
--- a/util.c
+++ b/util.c
@@ -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