From 286995a43141dda597766eeeba9504d0148575e8 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 10 Mar 2024 18:08:47 +0200 Subject: Add the U8_ARGS() macro --- lib/mbstring/rtou8.c | 4 ++-- lib/mbstring/u8chr.c | 4 ++-- lib/mbstring/u8cmp.c | 6 ++---- lib/mbstring/u8rchr.c | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) (limited to 'lib/mbstring') diff --git a/lib/mbstring/rtou8.c b/lib/mbstring/rtou8.c index 0ddac89..c11e89c 100644 --- a/lib/mbstring/rtou8.c +++ b/lib/mbstring/rtou8.c @@ -4,7 +4,7 @@ #include "rune.h" int -rtou8(char8_t *s, rune ch, size_t n) +rtou8(char8_t *s, size_t n, rune ch) { if (ch <= U8_1B_MAX) { if (n >= 1) @@ -33,5 +33,5 @@ rtou8(char8_t *s, rune ch, size_t n) return 4; } - return rtou8(s, RUNE_ERROR, n); + return rtou8(s, n, RUNE_ERROR); } diff --git a/lib/mbstring/u8chr.c b/lib/mbstring/u8chr.c index b7df221..2ce4e11 100644 --- a/lib/mbstring/u8chr.c +++ b/lib/mbstring/u8chr.c @@ -75,10 +75,10 @@ memmem4(const char8_t *h, size_t k, const char8_t *n) } char8_t * -u8chr(const char8_t *s, rune ch, size_t n) +u8chr(const char8_t *s, size_t n, rune ch) { char8_t buf[U8_LEN_MAX]; - int m = rtou8(buf, ch, sizeof(buf)); + int m = rtou8(buf, sizeof(buf), ch); if (n < (size_t)m) return nullptr; diff --git a/lib/mbstring/u8cmp.c b/lib/mbstring/u8cmp.c index 732896c..8bd2400 100644 --- a/lib/mbstring/u8cmp.c +++ b/lib/mbstring/u8cmp.c @@ -3,9 +3,7 @@ #include "mbstring.h" int -u8cmp(struct u8view x, struct u8view y) +u8cmp(const char8_t *x, size_t n, const char8_t *y, size_t m) { - if (x.len != y.len) - return x.len > y.len ? +1 : -1; - return memcmp(x.p, y.p, x.len); + return n != m ? (n > m ? +1 : -1) : memcmp(x, y, n); } diff --git a/lib/mbstring/u8rchr.c b/lib/mbstring/u8rchr.c index 1ffe445..df6be06 100644 --- a/lib/mbstring/u8rchr.c +++ b/lib/mbstring/u8rchr.c @@ -65,7 +65,7 @@ memrchr4(const char8_t *h, size_t k, const char8_t *n) } char8_t * -u8rchr(const char8_t *s, rune ch, size_t n) +u8rchr(const char8_t *s, size_t n, rune ch) { char8_t buf[U8_LEN_MAX]; int m = rtou8(buf, ch, sizeof(buf)); -- cgit v1.2.3