From 4f5361179ca6129df5dd0ffacad91f252d6871b8 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 7 Mar 2024 14:14:20 +0100 Subject: Add u8has(p s)fx --- lib/mbstring/u8haspfx.c | 9 +++++++++ lib/mbstring/u8hassfx.c | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 lib/mbstring/u8haspfx.c create mode 100644 lib/mbstring/u8hassfx.c (limited to 'lib') 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 + +#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 + +#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); +} -- cgit v1.2.3