From 0b34cadda2bc4da1cb0904989c8a5f2fe0236358 Mon Sep 17 00:00:00 2001 From: Tyge Lovset Date: Sun, 21 May 2023 23:30:25 +0200 Subject: NB! Made cstr.h header-only by default. Now requires #define i_static, i_implement or i_extern (includes utf8code.c) to implement non-inline functions (or link with libstc). --- include/stc/ccommon.h | 2 +- include/stc/cregex.h | 6 ++++-- include/stc/cstack.h | 6 +++--- include/stc/cstr.h | 1 + include/stc/csview.h | 1 - 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index e9d97d4b..eb3a6601 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -253,6 +253,6 @@ STC_INLINE intptr_t cnextpow2(intptr_t n) { #if defined(STC_EXTERN) #define i_extern #endif -#if defined(i_static) || defined(STC_IMPLEMENT) +#if defined(i_static) || defined(STC_IMPLEMENT) || defined(i_extern) #define i_implement #endif diff --git a/include/stc/cregex.h b/include/stc/cregex.h index f90acbf4..bf239ff6 100644 --- a/include/stc/cregex.h +++ b/include/stc/cregex.h @@ -160,12 +160,14 @@ cstr cregex_replace_pattern_6(const char* pattern, const char* input, const char void cregex_drop(cregex* re); #endif // CREGEX_H_INCLUDED -#if defined(i_extern) +#if defined i_extern || defined i_implement # include "../../src/cregex.c" +#endif +#if defined i_extern # include "../../src/utf8code.c" -# undef i_extern #endif #undef i_opt #undef i_header #undef i_static #undef i_implement +#undef i_extern diff --git a/include/stc/cstack.h b/include/stc/cstack.h index eb6ccb58..ae8b3c40 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -175,12 +175,12 @@ STC_INLINE i_keyraw _cx_memb(_value_toraw)(const _cx_value* val) #endif // !i_no_clone STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self) { - return c_LITERAL(_cx_iter){self->_len ? self->data : NULL, - self->data + self->_len}; + return c_LITERAL(_cx_iter){self->_len ? (_cx_value*)self->data : NULL, + (_cx_value*)self->data + self->_len}; } STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self) - { return c_LITERAL(_cx_iter){NULL, self->data + self->_len}; } + { return c_LITERAL(_cx_iter){NULL, (_cx_value*)self->data + self->_len}; } STC_INLINE void _cx_memb(_next)(_cx_iter* it) { if (++it->ref == it->end) it->ref = NULL; } diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 244b0a91..d496b85e 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -27,6 +27,7 @@ #ifndef CSTR_H_INCLUDED #define CSTR_H_INCLUDED +#define i_header #if defined i_extern || defined STC_EXTERN # define _i_extern #endif diff --git a/include/stc/csview.h b/include/stc/csview.h index bba3aea3..571bb278 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -24,7 +24,6 @@ #define CSVIEW_H_INCLUDED #include "ccommon.h" -#include "forward.h" #include "utf8.h" #define csview_NULL c_sv_1("") -- cgit v1.2.3