diff options
| author | Tyge Løvset <[email protected]> | 2022-01-17 08:32:08 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-01-17 08:32:08 +0100 |
| commit | df626f83dbf7789d622a1c5f4ff9fec3f61bc61b (patch) | |
| tree | 211a38d07e9ea653f0a8deabe5a63f425036e508 | |
| parent | 7ab5c49a47de856ea58a979cdc086ea22d8eceff (diff) | |
| download | STC-modified-df626f83dbf7789d622a1c5f4ff9fec3f61bc61b.tar.gz STC-modified-df626f83dbf7789d622a1c5f4ff9fec3f61bc61b.zip | |
Fixed object linkage declarations/definitions.
| -rw-r--r-- | include/stc/carr3.h | 2 | ||||
| -rw-r--r-- | include/stc/cregex.h | 5 | ||||
| -rw-r--r-- | include/stc/csmap.h | 18 | ||||
| -rw-r--r-- | include/stc/cstr.h | 18 | ||||
| -rw-r--r-- | include/stc/cvec.h | 19 | ||||
| -rw-r--r-- | include/stc/utf8.h | 9 |
6 files changed, 43 insertions, 28 deletions
diff --git a/include/stc/carr3.h b/include/stc/carr3.h index ec5cc88d..1cb0de19 100644 --- a/include/stc/carr3.h +++ b/include/stc/carr3.h @@ -129,7 +129,7 @@ STC_DEF _cx_self _cx_memb(_clone)(_cx_self src) { return _arr; } -STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { +STC_DEF void _cx_memb(_copy)(_cx_self *self, _cx_self other) { if (self->data == other.data) return; _cx_memb(_drop)(self); *self = _cx_memb(_clone)(other); } diff --git a/include/stc/cregex.h b/include/stc/cregex.h index 43196049..149cb7be 100644 --- a/include/stc/cregex.h +++ b/include/stc/cregex.h @@ -57,6 +57,9 @@ typedef enum { STC_INLINE cregex cregex_init(void) { cregex rx = {NULL}; return rx; } +STC_INLINE bool cregex_valid(cregex rx) + { return rx.nodes != NULL; } + /* create and compile a regular expression */ STC_API cregex cregex_new(const char *re); @@ -297,7 +300,7 @@ static bool _rx_or_is_match(cregex_node *node, const char *orig, } /* Global error value with callback address */ -struct { +static struct { cregex_error_t err; const char *s; jmp_buf buf; diff --git a/include/stc/csmap.h b/include/stc/csmap.h index 68e6e652..067bfd64 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -57,7 +57,6 @@ int main(void) { struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; };
#define _csmap_rep(self) c_container_of((self)->nodes, struct csmap_rep, nodes)
-static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0};
#endif // CSMAP_H_INCLUDED
#ifndef _i_prefix
@@ -102,6 +101,7 @@ STC_API _cx_value _cx_memb(_value_clone)(_cx_value _val); #if !defined _i_no_raw
STC_API _cx_result _cx_memb(_emplace)(_cx_self* self, i_keyraw rkey _i_MAP_ONLY(, i_valraw rmapped));
#endif
+STC_API _cx_self _cx_memb(_init)(void);
STC_API _cx_result _cx_memb(_insert)(_cx_self* self, i_key key _i_MAP_ONLY(, i_val mapped));
STC_API void _cx_memb(_drop)(_cx_self* self);
STC_API bool _cx_memb(_reserve)(_cx_self* self, size_t cap);
@@ -127,12 +127,6 @@ STC_INLINE _cx_value* _cx_memb(_get_mut)(_cx_self* self, i_keyraw rkey) { _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it); }
STC_INLINE _cx_self
-_cx_memb(_init)(void) {
- _cx_self tree = {(_cx_node *)_csmap_sentinel.nodes};
- return tree;
-}
-
-STC_INLINE _cx_self
_cx_memb(_with_capacity)(const size_t cap) {
_cx_self tree = _cx_memb(_init)();
_cx_memb(_reserve)(&tree, cap);
@@ -206,6 +200,16 @@ _cx_memb(_advance)(_cx_iter it, size_t n) { /* -------------------------- IMPLEMENTATION ------------------------- */
#if defined(_i_implement)
+#ifndef CSMAP_H_INCLUDED
+static struct csmap_rep _csmap_sentinel = {0, 0, 0, 0, 0};
+#endif
+
+STC_DEF _cx_self
+_cx_memb(_init)(void) {
+ _cx_self tree = {(_cx_node *)_csmap_sentinel.nodes};
+ return tree;
+}
+
STC_DEF _cx_value*
_cx_memb(_front)(const _cx_self* self) {
_cx_node *d = self->nodes;
diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 91bcc7ff..b99e5525 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -31,12 +31,14 @@ #include <stdio.h> /* vsnprintf */
#include <ctype.h>
-#define cstr_npos (SIZE_MAX >> 1)
-
-typedef struct { size_t size, cap; char str[]; } _cstr_rep_t;
+#define cstr_npos (SIZE_MAX >> 1)
+typedef struct { size_t size, cap; char str[]; } _cstr_rep_t;
#define _cstr_rep(self) c_container_of((self)->str, _cstr_rep_t, str)
-static struct { size_t size, cap; char str[1]; } _cstr_nullrep = {0, 0, {0}};
-static const cstr cstr_null = {_cstr_nullrep.str};
+#ifdef _i_static
+ static const cstr cstr_null;
+#else
+ extern const cstr cstr_null;
+#endif
/* optimal memory: based on malloc_usable_size() sequence: 24, 40, 56, ... */
#define _cstr_opt_mem(cap) ((((offsetof(_cstr_rep_t, str) + (cap) + 8)>>4)<<4) + 8)
@@ -173,6 +175,12 @@ c_strncasecmp(const char* s1, const char* s2, size_t nmax) { /* -------------------------- IMPLEMENTATION ------------------------- */
#if defined(_i_implement)
+static struct { size_t size, cap; char str[1]; } _cstr_nullrep = {0, 0, {0}};
+#ifdef _i_static
+static
+#endif
+const cstr cstr_null = {_cstr_nullrep.str};
+
STC_DEF size_t
cstr_reserve(cstr* self, const size_t cap) {
_cstr_rep_t* rep = _cstr_rep(self);
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index d9f6b18d..9278eada 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -66,7 +66,6 @@ int main() { struct cvec_rep { size_t size, cap; void* data[]; };
#define cvec_rep_(self) c_container_of((self)->data, struct cvec_rep, data)
-static struct cvec_rep _cvec_sentinel = {0, 0};
#endif // CVEC_H_INCLUDED
#ifndef _i_prefix
@@ -78,7 +77,7 @@ static struct cvec_rep _cvec_sentinel = {0, 0}; _cx_deftypes(_c_cvec_types, _cx_self, i_val);
#endif
typedef i_valraw _cx_raw;
-
+STC_API _cx_self _cx_memb(_init)(void);
STC_API void _cx_memb(_drop)(_cx_self* self);
STC_API void _cx_memb(_clear)(_cx_self* self);
STC_API bool _cx_memb(_reserve)(_cx_self* self, size_t cap);
@@ -150,12 +149,6 @@ STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs) STC_INLINE size_t _cx_memb(_index)(_cx_self cx, _cx_iter it) { return it.ref - cx.data; }
STC_INLINE _cx_self
-_cx_memb(_init)(void) {
- _cx_self cx = {(_cx_value *) _cvec_sentinel.data};
- return cx;
-}
-
-STC_INLINE _cx_self
_cx_memb(_with_size)(const size_t size, i_val null) {
_cx_self cx = _cx_memb(_init)();
_cx_memb(_resize)(&cx, size, null);
@@ -241,6 +234,16 @@ _cx_memb(_sort)(_cx_self* self) { /* -------------------------- IMPLEMENTATION ------------------------- */
#if defined(_i_implement)
+#ifndef CVEC_H_INCLUDED
+static struct cvec_rep _cvec_sentinel = {0, 0};
+#endif
+
+STC_DEF _cx_self
+_cx_memb(_init)(void) {
+ _cx_self cx = {(_cx_value *) _cvec_sentinel.data};
+ return cx;
+}
+
STC_DEF void
_cx_memb(_clear)(_cx_self* self) {
struct cvec_rep* rep = cvec_rep_(self);
diff --git a/include/stc/utf8.h b/include/stc/utf8.h index 4270c8c7..e84a9b7e 100644 --- a/include/stc/utf8.h +++ b/include/stc/utf8.h @@ -70,12 +70,9 @@ STC_INLINE const char *utf8_next(const char *s) { // --------------------------- IMPLEMENTATION ---------------------------------
// Copyright (c) 2008-2009 Bjoern Hoehrmann <[email protected]>
// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
-
#ifdef _i_implement
-#ifdef _i_static
-static
-#endif
-const uint8_t utf8_table[] = {
+
+static const uint8_t utf8_table[] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -88,7 +85,7 @@ const uint8_t utf8_table[] = { 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
- 12,36,12,12,12,12,12,12,12,12,12,12,
+ 12,36,12,12,12,12,12,12,12,12,12,12,
};
STC_DEF uint32_t utf8_decode(uint32_t *state, uint32_t *codep,
|
