diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-01-21 03:03:58 +0100 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-01-21 03:03:58 +0100 |
commit | 4f93f935dc7a981ca073a322425c3f5929ffb644 (patch) | |
tree | 4460586408ec7fdfcecf3ba4584f0435067125a6 /vendor/librune/include/internal/common.h | |
parent | 72ea25a4d73e3e026366d4165f5bc4ec9e7418cb (diff) |
Support line- & column-based match locations
Diffstat (limited to 'vendor/librune/include/internal/common.h')
-rw-r--r-- | vendor/librune/include/internal/common.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/librune/include/internal/common.h b/vendor/librune/include/internal/common.h new file mode 100644 index 0000000..7107528 --- /dev/null +++ b/vendor/librune/include/internal/common.h @@ -0,0 +1,39 @@ +#ifndef RUNE_INTERNAL_COMMON_H +#define RUNE_INTERNAL_COMMON_H + +#if __STDC_VERSION__ >= 202311L +# define RUNE_IS_23 1 +#endif + +#if !RUNE_IS_23 +# include <stddef.h> /* IWYU pragma: export */ +# define nullptr NULL +#endif + +#ifndef unreachable +# if RUNE_IS_23 +# include <stddef.h> /* IWYU pragma: export */ +# elif defined(__GNUC__) || defined(__clang__) +# define unreachable() __builtin_unreachable() +# else +# define unreachable() \ + do \ + *(int *)0 = 0; \ + while (0) +# endif +#endif + +#define U1(x) (((x)&0x80) == 0x00) +#define U2(x) (((x)&0xE0) == 0xC0) +#define U3(x) (((x)&0xF0) == 0xE0) +#define U4(x) (((x)&0xF8) == 0xF0) +#define UC(x) (((x)&0xC0) == 0x80) + +/* Maximum value of a 1–4-byte long UTF-8 sequence */ +#include "rune.h" +#define _1B_MAX RUNE_C(0x00007F) +#define _2B_MAX RUNE_C(0x0007FF) +#define _3B_MAX RUNE_C(0x00FFFF) +#define _4B_MAX RUNE_C(0x10FFFF) + +#endif /* !RUNE_INTERNAL_COMMON_H */ |