aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbstring.h2
-rw-r--r--lib/mbstring/u8haspfx.c9
-rw-r--r--lib/mbstring/u8hassfx.c9
3 files changed, 20 insertions, 0 deletions
diff --git a/include/mbstring.h b/include/mbstring.h
index 15250ff..e23a00b 100644
--- a/include/mbstring.h
+++ b/include/mbstring.h
@@ -34,6 +34,8 @@ struct u8view {
#define PRIsU8 ".*s"
#define U8_PRI_ARGS(sv) ((int)(sv).len), ((sv).p)
+bool u8haspfx(const char8_t *, size_t, const char8_t *, size_t);
+bool u8hassfx(const char8_t *, size_t, const char8_t *, size_t);
char8_t *u8chk(const char8_t *, size_t);
char8_t *u8chr(const char8_t *, rune, size_t);
char8_t *u8rchr(const char8_t *, rune, size_t);
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);
+}