aboutsummaryrefslogtreecommitdiff
path: root/lib/mbstring
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-03-31 20:08:09 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-03-31 20:08:09 +0200
commit8e9c592f1af6d4e428fe65362cce36a39f5844f0 (patch)
tree2b6628313c75989b415162b4eec35ba85653a832 /lib/mbstring
parenta61379f455b80236e251c56c32a16748f2d35af3 (diff)
Prefer constexpr, and rename U8_BYTE_*()
Diffstat (limited to 'lib/mbstring')
-rw-r--r--lib/mbstring/u8prev.c15
-rw-r--r--lib/mbstring/u8tor.c10
2 files changed, 12 insertions, 13 deletions
diff --git a/lib/mbstring/u8prev.c b/lib/mbstring/u8prev.c
index 507f7e1..ff580c2 100644
--- a/lib/mbstring/u8prev.c
+++ b/lib/mbstring/u8prev.c
@@ -12,23 +12,22 @@ u8prev(rune *ch, const char8_t **p, const char8_t *start)
if (d <= 0) {
return 0;
- } else if (U8_BYTE_1(s[-1])) {
+ } else if (u8byte1(s[-1])) {
if (ch)
*ch = s[-1];
off = 1;
- } else if (d > 1 && U8_BYTE_C(s[-1]) && U8_BYTE_2(s[-2])) {
+ } else if (d > 1 && u8bytec(s[-1]) && u8byte2(s[-2])) {
if (ch)
*ch = ((s[-2] & 0x1F) << 6) | (s[-1] & 0x3F);
off = 2;
- } else if (d > 2 && U8_BYTE_C(s[-1]) && U8_BYTE_C(s[-2])
- && U8_BYTE_3(s[-3])) {
+ } else if (d > 2 && u8bytec(s[-1]) && u8bytec(s[-2]) && u8byte3(s[-3])) {
if (ch) {
- *ch =
- ((s[-3] & 0x0F) << 12) | ((s[-2] & 0x3F) << 6) | (s[-1] & 0x3F);
+ *ch = ((s[-3] & 0x0F) << 12) | ((s[-2] & 0x3F) << 6)
+ | (s[-1] & 0x3F);
}
off = 3;
- } else if (d > 3 && U8_BYTE_C(s[-1]) && U8_BYTE_C(s[-2]) && U8_BYTE_C(s[-3])
- && U8_BYTE_4(s[-4])) {
+ } else if (d > 3 && u8bytec(s[-1]) && u8bytec(s[-2]) && u8bytec(s[-3])
+ && u8byte4(s[-4])) {
if (ch) {
*ch = ((s[-4] & 0x07) << 18) | ((s[-3] & 0x3F) << 12)
| ((s[-2] & 0x3F) << 6) | (s[-1] & 0x3F);
diff --git a/lib/mbstring/u8tor.c b/lib/mbstring/u8tor.c
index 85c4c19..eb54689 100644
--- a/lib/mbstring/u8tor.c
+++ b/lib/mbstring/u8tor.c
@@ -4,17 +4,17 @@
int
u8tor(rune *ch, const char8_t *s)
{
- if (U8_BYTE_1(s[0])) {
+ if (u8byte1(s[0])) {
*ch = s[0];
return 1;
- } else if (U8_BYTE_2(s[0]) && U8_BYTE_C(s[1])) {
+ } else if (u8byte2(s[0]) && u8bytec(s[1])) {
*ch = ((s[0] & 0x1F) << 6) | (s[1] & 0x3F);
return 2;
- } else if (U8_BYTE_3(s[0]) && U8_BYTE_C(s[1]) && U8_BYTE_C(s[2])) {
+ } else if (u8byte3(s[0]) && u8bytec(s[1]) && u8bytec(s[2])) {
*ch = ((s[0] & 0x0F) << 12) | ((s[1] & 0x3F) << 6) | (s[2] & 0x3F);
return 3;
- } else if (U8_BYTE_4(s[0]) && U8_BYTE_C(s[1]) && U8_BYTE_C(s[2])
- && U8_BYTE_C(s[3])) {
+ } else if (u8byte4(s[0]) && u8bytec(s[1]) && u8bytec(s[2])
+ && u8bytec(s[3])) {
*ch = ((s[0] & 0x07) << 18) | ((s[1] & 0x3F) << 12)
| ((s[2] & 0x3F) << 6) | (s[3] & 0x3F);
return 4;