aboutsummaryrefslogtreecommitdiff
path: root/include/mbstring.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbstring.h')
-rw-r--r--include/mbstring.h43
1 files changed, 15 insertions, 28 deletions
diff --git a/include/mbstring.h b/include/mbstring.h
index d908284..ba654bb 100644
--- a/include/mbstring.h
+++ b/include/mbstring.h
@@ -4,14 +4,13 @@
#include <stddef.h>
#include "_charN_t.h"
-#include "_qmacros.h"
#include "_rune.h"
#include "_u8view.h"
#define U8(...) \
((struct u8view){__VA_OPT__(u8##__VA_ARGS__, sizeof(u8##__VA_ARGS__) - 1)})
-#define U8_ARGS(s) ((s).p), ((s).len)
-#define U8_ARGSP(s) (&(s).p), (&(s).len)
+
+#define VSHFT(sv, n) ((sv)->p += (n), (sv)->len -= (n))
/* clang-format off */
#define u8byte1(x) (((x) & 0x80) == 0x00)
@@ -29,33 +28,21 @@ constexpr rune U8_4B_MAX = 0x10FFFF;
constexpr int U8_LEN_MAX = 4;
#define PRIsU8 ".*s"
-#define U8_PRI_ARGS(sv) ((int)(sv).len), ((sv).p)
-
-[[nodiscard]] bool u8haspfx(const char8_t *, size_t, const char8_t *, size_t);
-[[nodiscard]] bool u8hassfx(const char8_t *, size_t, const char8_t *, size_t);
-
-[[nodiscard]] char8_t *u8chk(const char8_t *, size_t);
-
-[[nodiscard]] char8_t *u8chr(const char8_t *, size_t, rune);
-[[nodiscard]] char8_t *u8rchr(const char8_t *, size_t, rune);
+#define SV_PRI_ARGS(sv) ((int)(sv).len), ((sv).p)
int rtou8(char8_t *, size_t, rune);
-int u8tor(rune *, const char8_t *);
-
-[[nodiscard]] int u8cmp(const char8_t *, size_t, const char8_t *, size_t);
-
-int u8next(rune *, const char8_t **, size_t *);
+int u8next(rune *, struct u8view *);
int u8prev(rune *, const char8_t **, const char8_t *);
-
-[[nodiscard]] size_t u8spn(const char8_t *, size_t, const rune *, size_t);
-[[nodiscard]] size_t u8cspn(const char8_t *, size_t, const rune *, size_t);
-
-[[nodiscard]] size_t u8len(const char8_t *, size_t);
-
-struct u8view u8split(const char8_t **, size_t *, rune);
-
-#define u8chk(s, n) _MLIB_Q_PTR(char8_t, u8chk, (s), (s), (n))
-#define u8chr(s, n, ch) _MLIB_Q_PTR(char8_t, u8chr, (s), (s), (n), (ch))
-#define u8rchr(s, n, ch) _MLIB_Q_PTR(char8_t, u8rchr, (s), (s), (n), (ch))
+int u8tor(rune *, const char8_t *);
+[[nodiscard]] bool u8haspfx(struct u8view, struct u8view);
+[[nodiscard]] bool u8hassfx(struct u8view, struct u8view);
+[[nodiscard]] const char8_t *u8chk(struct u8view);
+[[nodiscard]] const char8_t *u8chr(struct u8view, rune);
+[[nodiscard]] const char8_t *u8rchr(struct u8view, rune);
+[[nodiscard]] int u8cmp(struct u8view, struct u8view);
+[[nodiscard]] size_t u8cspn(struct u8view, const rune *, size_t);
+[[nodiscard]] size_t u8len(struct u8view);
+[[nodiscard]] size_t u8spn(struct u8view, const rune *, size_t);
+struct u8view u8split(struct u8view *, rune);
#endif /* !MLIB_MBSTRING_H */