diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-03-10 18:08:47 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-03-10 18:08:47 +0200 |
commit | 286995a43141dda597766eeeba9504d0148575e8 (patch) | |
tree | dbf76fb7826e06c4d5d3506409068408128aa39d /lib/mbstring | |
parent | 7f4efec068c74c027b7dcb07c7ea93aacaaecc60 (diff) |
Add the U8_ARGS() macro
Diffstat (limited to 'lib/mbstring')
-rw-r--r-- | lib/mbstring/rtou8.c | 4 | ||||
-rw-r--r-- | lib/mbstring/u8chr.c | 4 | ||||
-rw-r--r-- | lib/mbstring/u8cmp.c | 6 | ||||
-rw-r--r-- | lib/mbstring/u8rchr.c | 2 |
4 files changed, 7 insertions, 9 deletions
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)); |