summaryrefslogtreecommitdiffhomepage
path: root/include/stc/utf8.h
diff options
context:
space:
mode:
author_Tradam <[email protected]>2023-09-08 01:29:47 +0000
committerGitHub <[email protected]>2023-09-08 01:29:47 +0000
commit3c76c7f3d5db3f9586a90d03f8fbb02d79de9acd (patch)
treeafbe4b540967223911f7c5de36559b82154f02f3 /include/stc/utf8.h
parent0841165881871ee01b782129be681209aeed2423 (diff)
parent1a72205fe05c2375cfd380dd8381a8460d9ed8d1 (diff)
downloadSTC-modified-modified.tar.gz
STC-modified-modified.zip
Merge branch 'stclib:master' into modifiedHEADmodified
Diffstat (limited to 'include/stc/utf8.h')
-rw-r--r--include/stc/utf8.h43
1 files changed, 37 insertions, 6 deletions
diff --git a/include/stc/utf8.h b/include/stc/utf8.h
index a4cc3846..6d12856f 100644
--- a/include/stc/utf8.h
+++ b/include/stc/utf8.h
@@ -1,11 +1,34 @@
+/* MIT License
+ *
+ * Copyright (c) 2023 Tyge Løvset
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#include "priv/linkage.h"
+
#ifndef UTF8_H_INCLUDED
#define UTF8_H_INCLUDED
+#include "ccommon.h"
#include <ctype.h>
#include "forward.h"
-#include "ccommon.h"
-// utf8 methods defined in src/utf8code.c:
enum {
U8G_Cc, U8G_Lt, U8G_Nd, U8G_Nl,
U8G_Pc, U8G_Pd, U8G_Pf, U8G_Pi,
@@ -16,6 +39,7 @@ enum {
U8G_SIZE
};
+// utf8 methods defined in src/utf8code.c:
extern bool utf8_isgroup(int group, uint32_t c);
extern bool utf8_isalpha(uint32_t c);
extern uint32_t utf8_casefold(uint32_t c);
@@ -51,9 +75,9 @@ STC_INLINE bool utf8_isspace(uint32_t c) {
/* decode next utf8 codepoint. https://bjoern.hoehrmann.de/utf-8/decoder/dfa */
typedef struct { uint32_t state, codep; } utf8_decode_t;
+extern const uint8_t utf8_dtab[]; /* utf8code.c */
STC_INLINE uint32_t utf8_decode(utf8_decode_t* d, const uint32_t byte) {
- extern const uint8_t utf8_dtab[]; /* utf8code.c */
const uint32_t type = utf8_dtab[byte];
d->codep = d->state ? (byte & 0x3fu) | (d->codep << 6)
: (0xffU >> type) & byte;
@@ -112,9 +136,16 @@ STC_INLINE const char* utf8_at(const char *s, intptr_t index) {
STC_INLINE intptr_t utf8_pos(const char* s, intptr_t index)
{ return (intptr_t)(utf8_at(s, index) - s); }
-
#endif // UTF8_H_INCLUDED
-#if defined(i_extern)
+
+#if defined i_import || (defined i_implement && !defined _i_inc_utf8)
# include "../../src/utf8code.c"
-# undef i_extern
#endif
+#ifndef _i_inc_utf8
+#undef i_static
+#undef i_header
+#undef i_implement
+#undef i_import
+#undef i_opt
+#endif
+#undef _i_inc_utf8