aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-03-07 14:14:20 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-03-07 14:14:20 +0100
commit4f5361179ca6129df5dd0ffacad91f252d6871b8 (patch)
tree769907fc3e947b59ccf952160a17d37fc8a01e5c /lib
parent02f5d70e400f882c9da25f5b9e0cd1f083cbdf2f (diff)
Add u8has(p s)fx
Diffstat (limited to 'lib')
-rw-r--r--lib/mbstring/u8haspfx.c9
-rw-r--r--lib/mbstring/u8hassfx.c9
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/mbstring/u8haspfx.c b/lib/mbstring/u8haspfx.c
new file mode 100644
index 0000000..9b5ae66
--- /dev/null
+++ b/lib/mbstring/u8haspfx.c
@@ -0,0 +1,9 @@
+#include <string.h>
+
+#include "mbstring.h"
+
+bool
+u8haspfx(const char8_t *s, size_t n, const char8_t *pfx, size_t m)
+{
+ return n >= m && memcmp(s, pfx, m);
+}
diff --git a/lib/mbstring/u8hassfx.c b/lib/mbstring/u8hassfx.c
new file mode 100644
index 0000000..8ca5f96
--- /dev/null
+++ b/lib/mbstring/u8hassfx.c
@@ -0,0 +1,9 @@
+#include <string.h>
+
+#include "mbstring.h"
+
+bool
+u8hassfx(const char8_t *s, size_t n, const char8_t *sfx, size_t m)
+{
+ return n >= m && memcmp(s + n - m, sfx, m);
+}