aboutsummaryrefslogtreecommitdiff
path: root/vendor/librune/include/internal
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-01-29 00:42:05 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-01-29 00:42:05 +0100
commitb8f4479a17e1add06e1532a00ae913cc0f4e9567 (patch)
treec724d7e1cb053b35cefd87d02109abac846fe0a5 /vendor/librune/include/internal
parent3d9a150f522278f8ab37e299f9aa187931ea2d56 (diff)
Bump librune
Diffstat (limited to 'vendor/librune/include/internal')
-rw-r--r--vendor/librune/include/internal/common.h6
-rw-r--r--vendor/librune/include/internal/rtype/cat.h (renamed from vendor/librune/include/internal/rtype_lookup.h)78
-rw-r--r--vendor/librune/include/internal/rtype/lookup-func.h47
3 files changed, 61 insertions, 70 deletions
diff --git a/vendor/librune/include/internal/common.h b/vendor/librune/include/internal/common.h
index ace9e63..a05f33c 100644
--- a/vendor/librune/include/internal/common.h
+++ b/vendor/librune/include/internal/common.h
@@ -3,6 +3,8 @@
/* IWYU pragma: private */
+#include <limits.h>
+
#define lengthof(a) (sizeof(a) / sizeof(*(a)))
#define U1(x) (((x)&0x80) == 0x00)
@@ -20,4 +22,8 @@
#define LATIN1_MAX 0xFF
+#if BITINT_MAXWIDTH >= LATIN1_MAX + 1
+# define BIT_LOOKUP 1
+#endif
+
#endif /* !RUNE_INTERNAL_COMMON_H */
diff --git a/vendor/librune/include/internal/rtype_lookup.h b/vendor/librune/include/internal/rtype/cat.h
index b4b41fd..d84082a 100644
--- a/vendor/librune/include/internal/rtype_lookup.h
+++ b/vendor/librune/include/internal/rtype/cat.h
@@ -1,17 +1,15 @@
-/* This file is autogenerated by gen/gbrk; DO NOT EDIT. */
+/* This file is autogenerated by gen/rtype-cat; DO NOT EDIT. */
-/* TODO: Change tables to constexpr from const when Clangd gets better */
-
-#ifndef RUNE_INTERNAL_RTYPE_LOOKUP_H
-#define RUNE_INTERNAL_RTYPE_LOOKUP_H
+#ifndef RUNE_INTERNAL_RTYPE_CAT_H
+#define RUNE_INTERNAL_RTYPE_CAT_H
/* IWYU pragma: private */
/* clang-format off */
-#include "types.h"
-#include "../rtype.h"
+#include "../types.h"
+#include "../../rtype.h"
-static const unicat rtype_lat1_tbl[] = {
+static const enum unicat rtype_cat_lat1_tbl[] = {
UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC,
UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC,
UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC, UC_CC,
@@ -48,68 +46,8 @@ static const unicat rtype_lat1_tbl[] = {
static const struct {
rune lo, hi;
- unicat cat;
+ enum unicat val;
} rtype_cat_tbl[] = {
- {0x000000, 0x00001F, UC_CC},
- {0x000020, 0x000020, UC_ZS},
- {0x000021, 0x000023, UC_PO},
- {0x000024, 0x000024, UC_SC},
- {0x000025, 0x000027, UC_PO},
- {0x000028, 0x000028, UC_PS},
- {0x000029, 0x000029, UC_PE},
- {0x00002A, 0x00002A, UC_PO},
- {0x00002B, 0x00002B, UC_SM},
- {0x00002C, 0x00002C, UC_PO},
- {0x00002D, 0x00002D, UC_PD},
- {0x00002E, 0x00002F, UC_PO},
- {0x000030, 0x000039, UC_ND},
- {0x00003A, 0x00003B, UC_PO},
- {0x00003C, 0x00003E, UC_SM},
- {0x00003F, 0x000040, UC_PO},
- {0x000041, 0x00005A, UC_LU},
- {0x00005B, 0x00005B, UC_PS},
- {0x00005C, 0x00005C, UC_PO},
- {0x00005D, 0x00005D, UC_PE},
- {0x00005E, 0x00005E, UC_SK},
- {0x00005F, 0x00005F, UC_PC},
- {0x000060, 0x000060, UC_SK},
- {0x000061, 0x00007A, UC_LL},
- {0x00007B, 0x00007B, UC_PS},
- {0x00007C, 0x00007C, UC_SM},
- {0x00007D, 0x00007D, UC_PE},
- {0x00007E, 0x00007E, UC_SM},
- {0x00007F, 0x00009F, UC_CC},
- {0x0000A0, 0x0000A0, UC_ZS},
- {0x0000A1, 0x0000A1, UC_PO},
- {0x0000A2, 0x0000A5, UC_SC},
- {0x0000A6, 0x0000A6, UC_SO},
- {0x0000A7, 0x0000A7, UC_PO},
- {0x0000A8, 0x0000A8, UC_SK},
- {0x0000A9, 0x0000A9, UC_SO},
- {0x0000AA, 0x0000AA, UC_LO},
- {0x0000AB, 0x0000AB, UC_PI},
- {0x0000AC, 0x0000AC, UC_SM},
- {0x0000AD, 0x0000AD, UC_CF},
- {0x0000AE, 0x0000AE, UC_SO},
- {0x0000AF, 0x0000AF, UC_SK},
- {0x0000B0, 0x0000B0, UC_SO},
- {0x0000B1, 0x0000B1, UC_SM},
- {0x0000B2, 0x0000B3, UC_NO},
- {0x0000B4, 0x0000B4, UC_SK},
- {0x0000B5, 0x0000B5, UC_LL},
- {0x0000B6, 0x0000B7, UC_PO},
- {0x0000B8, 0x0000B8, UC_SK},
- {0x0000B9, 0x0000B9, UC_NO},
- {0x0000BA, 0x0000BA, UC_LO},
- {0x0000BB, 0x0000BB, UC_PF},
- {0x0000BC, 0x0000BE, UC_NO},
- {0x0000BF, 0x0000BF, UC_PO},
- {0x0000C0, 0x0000D6, UC_LU},
- {0x0000D7, 0x0000D7, UC_SM},
- {0x0000D8, 0x0000DE, UC_LU},
- {0x0000DF, 0x0000F6, UC_LL},
- {0x0000F7, 0x0000F7, UC_SM},
- {0x0000F8, 0x0000FF, UC_LL},
{0x000100, 0x000100, UC_LU},
{0x000101, 0x000101, UC_LL},
{0x000102, 0x000102, UC_LU},
@@ -3354,4 +3292,4 @@ static const struct {
{0x100000, 0x10FFFD, UC_CO},
};
-#endif /* !RUNE_INTERNAL_RTYPE_LOOKUP_H */
+#endif /* !RUNE_INTERNAL_RTYPE_CAT_H */
diff --git a/vendor/librune/include/internal/rtype/lookup-func.h b/vendor/librune/include/internal/rtype/lookup-func.h
new file mode 100644
index 0000000..91bda8b
--- /dev/null
+++ b/vendor/librune/include/internal/rtype/lookup-func.h
@@ -0,0 +1,47 @@
+#include <stddef.h>
+
+#include "internal/common.h"
+
+#ifndef TYPE
+# error "TYPE if not defined"
+#endif
+#ifndef DEFAULT
+# error "DEFAULT is not defined"
+#endif
+#ifndef TABLE
+# error "TABLE is not defined"
+#endif
+#ifndef HAS_VALUE
+# error "HAS_VALUE is not defined"
+#endif
+
+[[gnu::always_inline]] static TYPE
+lookup(rune ch)
+{
+ ptrdiff_t lo, hi;
+
+#ifdef LATIN1_TABLE
+ if (ch <= LATIN1_MAX)
+ return LATIN1_TABLE[ch];
+#endif
+
+ lo = 0;
+ hi = lengthof(TABLE) - 1;
+
+ while (lo <= hi) {
+ ptrdiff_t i = (lo + hi) / 2;
+
+ if (ch < TABLE[i].lo)
+ hi = i - 1;
+ else if (ch > TABLE[i].hi)
+ lo = i + 1;
+ else
+#if HAS_VALUE
+ return TABLE[i].val;
+#else
+ return true;
+#endif
+ }
+
+ return DEFAULT;
+}