aboutsummaryrefslogtreecommitdiff
path: root/vendor/librune/lib/utf8/u8rchr.c
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-27 23:26:42 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-27 23:26:42 +0100
commit679f7928e27a95e559eb3a69febf0c6336e40234 (patch)
treeaf9c5bb35253086eb8e3ad3d7774e7349b3beefe /vendor/librune/lib/utf8/u8rchr.c
parentfd502fd87b40ae7f60314d8d9009f739f1c5fcf3 (diff)
Bump librune
Diffstat (limited to 'vendor/librune/lib/utf8/u8rchr.c')
-rw-r--r--vendor/librune/lib/utf8/u8rchr.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/vendor/librune/lib/utf8/u8rchr.c b/vendor/librune/lib/utf8/u8rchr.c
index 15fff51..b2668e4 100644
--- a/vendor/librune/lib/utf8/u8rchr.c
+++ b/vendor/librune/lib/utf8/u8rchr.c
@@ -1,20 +1,20 @@
+#include <stddef.h>
#include <stdint.h>
+#define _RUNE_NO_MACRO_WRAPPER 1
#include "utf8.h"
-#include "internal/common.h"
-
-static const char8_t *
+static char8_t *
memrchr1(const char8_t *s, size_t k, const char8_t *n)
{
for (const char8_t *p = s + k - 1; k-- > 0; p--) {
if (*p == *n)
- return p;
+ return (char8_t *)p;
}
return nullptr;
}
-static const char8_t *
+static char8_t *
memrchr2(const char8_t *h, size_t k, const char8_t *n)
{
uint16_t hw, nw;
@@ -24,13 +24,13 @@ memrchr2(const char8_t *h, size_t k, const char8_t *n)
for (H -= 2, k -= 2; k; k--, hw = hw >> 8 | (*H-- << 8)) {
if (hw == nw)
- return H + 1;
+ return (char8_t *)H + 1;
}
- return hw == nw ? H + 1 : nullptr;
+ return hw == nw ? (char8_t *)H + 1 : nullptr;
}
-static const char8_t *
+static char8_t *
memrchr3(const char8_t *h, size_t k, const char8_t *n)
{
uint32_t hw, nw;
@@ -42,13 +42,13 @@ memrchr3(const char8_t *h, size_t k, const char8_t *n)
k--, hw = (hw >> 8 | (*H-- << 24)) & UINT32_C(0xFFFFFF00))
{
if (hw == nw)
- return H + 1;
+ return (char8_t *)H + 1;
}
- return hw == nw ? H + 1 : nullptr;
+ return hw == nw ? (char8_t *)H + 1 : nullptr;
}
-static const char8_t *
+static char8_t *
memrchr4(const char8_t *h, size_t k, const char8_t *n)
{
uint32_t hw, nw;
@@ -58,13 +58,13 @@ memrchr4(const char8_t *h, size_t k, const char8_t *n)
for (H -= 4, k -= 4; k; k--, hw = hw >> 8 | (*H-- << 24)) {
if (hw == nw)
- return H + 1;
+ return (char8_t *)H + 1;
}
- return hw == nw ? H + 1 : nullptr;
+ return hw == nw ? (char8_t *)H + 1 : nullptr;
}
-const char8_t *
+char8_t *
u8rchr(const char8_t *s, rune ch, size_t n)
{
char8_t buf[U8_LEN_MAX];
@@ -74,13 +74,13 @@ u8rchr(const char8_t *s, rune ch, size_t n)
return nullptr;
switch (m) {
case 1:
- return memrchr1(s, n, buf);
+ return (char8_t *)memrchr1(s, n, buf);
case 2:
- return memrchr2(s, n, buf);
+ return (char8_t *)memrchr2(s, n, buf);
case 3:
- return memrchr3(s, n, buf);
+ return (char8_t *)memrchr3(s, n, buf);
case 4:
- return memrchr4(s, n, buf);
+ return (char8_t *)memrchr4(s, n, buf);
}
unreachable();