summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-06-09 22:37:15 +0200
committerTyge Løvset <[email protected]>2023-06-09 22:37:15 +0200
commit5f935739d2ce280beda36c7a7ddb0e0ee34c8fb3 (patch)
tree2cdd210fefa5eae54a384f980442195659a77fac
parent72b0f0e7839b487a5df7c79ffe84511480cad251 (diff)
downloadSTC-modified-5f935739d2ce280beda36c7a7ddb0e0ee34c8fb3.tar.gz
STC-modified-5f935739d2ce280beda36c7a7ddb0e0ee34c8fb3.zip
Rename i_extern template flag to i_import. i_extern still available, but deprecated.
-rw-r--r--README.md6
-rw-r--r--docs/clist_api.md1
-rw-r--r--docs/cregex_api.md4
-rw-r--r--docs/csview_api.md4
-rw-r--r--include/stc/ccommon.h8
-rw-r--r--include/stc/crand.h2
-rw-r--r--include/stc/cregex.h4
-rw-r--r--include/stc/cspan.h2
-rw-r--r--include/stc/cstr.h10
-rw-r--r--include/stc/csview.h5
-rw-r--r--include/stc/priv/template2.h2
-rw-r--r--include/stc/utf8.h4
-rw-r--r--misc/examples/forfilter.c2
-rw-r--r--misc/examples/regex1.c2
-rw-r--r--misc/examples/regex2.c2
-rw-r--r--misc/examples/regex_match.c2
-rw-r--r--misc/examples/regex_replace.c2
-rw-r--r--misc/examples/splitstr.c2
-rw-r--r--misc/tests/cregex_test.c2
-rw-r--r--src/cregex.c2
-rw-r--r--src/libstc.c4
21 files changed, 35 insertions, 37 deletions
diff --git a/README.md b/README.md
index e63a56e4..f14858e7 100644
--- a/README.md
+++ b/README.md
@@ -333,6 +333,7 @@ After erasing the elements found:
---
## Installation
+*NEEDS REWRITE!*
Because it is headers-only, headers can simply be included in your program. By default, functions are static
(some inlined). You may add the *include* folder to the **CPATH** environment variable to
let GCC, Clang, and TinyC locate the headers.
@@ -345,8 +346,7 @@ You may also cherry-pick shared linking mode on individual containers by `#defin
`#define i_implement`, or force static symbols by `#define i_static` before container includes.
As a special case, there may be non-templated functions in templated containers that should be implemented only
-once and if needed. Currently, define `i_extern` before including **clist** for its sorting function, and before
-**cregex** or **utf8** to implement them (global `STC_EXTERN` can alternatively be defined).
+once and if needed. Currently, define `i_import` before including **cregex** or **utf8** to implement them.
It is possible to generate single headers by executing the python script `src/singleheader.py header-file > single`.
@@ -356,7 +356,7 @@ or define your own, e.g.:
```c
// stc_libs.c
#define STC_IMPLEMENT // implement all the following as shared objects
-
+#define i_implement
#include <stc/cstr.h>
#include "Point.h"
diff --git a/docs/clist_api.md b/docs/clist_api.md
index 36935c88..51b7af6a 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -118,7 +118,6 @@ Interleave *push_front()* / *push_back()* then *sort()*:
```c
#define i_type DList
#define i_val double
-#define i_extern // link with sort() fn.
#include <stc/clist.h>
#include <stdio.h>
diff --git a/docs/cregex_api.md b/docs/cregex_api.md
index fc86cc63..ff69c549 100644
--- a/docs/cregex_api.md
+++ b/docs/cregex_api.md
@@ -99,7 +99,7 @@ If an error occurs ```cregex_compile``` returns a negative error code stored in
[ [Run this code](https://godbolt.org/z/z434TMKfo) ]
```c
-#define i_extern // include external cstr, utf8, cregex functions implementation.
+#define i_import // include dependent cstr, utf8 and cregex function definitions.
#include <stc/cregex.h>
int main() {
@@ -151,7 +151,7 @@ c_formatch (it, &re, input)
## Using cregex in a project
-The easiest is to `#define i_extern` before `#include <stc/cregex.h>`. Make sure to do that in one translation unit only.
+The easiest is to `#define i_import` before `#include <stc/cregex.h>`. Make sure to do that in one translation unit only.
For reference, **cregex** uses the following files:
- `stc/cregex.h`, `stc/utf8.h`, `stc/csview.h`, `stc/cstr.h`, `stc/ccommon.h`, `stc/forward.h`
diff --git a/docs/csview_api.md b/docs/csview_api.md
index b697b7d6..879822d3 100644
--- a/docs/csview_api.md
+++ b/docs/csview_api.md
@@ -148,8 +148,8 @@ red Apples
### Example 2: UTF8 handling
```c
-#define i_extern
-#include <stc/cstr.h> // i_extern: implement cstr + dependencies (utf8)
+#define i_import // include dependent cstr, utf8 and cregex function definitions.
+#include <stc/cstr.h>
int main()
{
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 87522a6e..e491a567 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -241,6 +241,9 @@ STC_INLINE intptr_t cnextpow2(intptr_t n) {
#undef STC_API
#undef STC_DEF
+#ifdef i_extern
+# define i_import
+#endif
#if !defined(i_static) && !defined(STC_STATIC) && (defined(i_header) || defined(STC_HEADER) || \
defined(i_implement) || defined(STC_IMPLEMENT))
#define STC_API extern
@@ -250,9 +253,6 @@ STC_INLINE intptr_t cnextpow2(intptr_t n) {
#define STC_API static inline
#define STC_DEF static inline
#endif
-#if defined(STC_EXTERN)
- #define i_extern
-#endif
-#if defined(STC_IMPLEMENT) || defined(i_extern)
+#if defined(STC_IMPLEMENT) || defined(i_import)
#define i_implement
#endif
diff --git a/include/stc/crand.h b/include/stc/crand.h
index b9687c01..95a65fb0 100644
--- a/include/stc/crand.h
+++ b/include/stc/crand.h
@@ -158,4 +158,4 @@ STC_DEF double crand_norm(crand_t* rng, crand_norm_t* dist) {
#undef i_static
#undef i_header
#undef i_implement
-#undef i_extern
+#undef i_import
diff --git a/include/stc/cregex.h b/include/stc/cregex.h
index e6180a31..43a7fcbf 100644
--- a/include/stc/cregex.h
+++ b/include/stc/cregex.h
@@ -161,12 +161,12 @@ void cregex_drop(cregex* re);
#if defined i_implement
# include "../../src/cregex.c"
#endif
-#if defined i_extern
+#if defined i_import
# include "../../src/utf8code.c"
#endif
#endif // CREGEX_H_INCLUDED
#undef i_opt
#undef i_header
#undef i_static
-#undef i_extern
+#undef i_import
#undef i_implement
diff --git a/include/stc/cspan.h b/include/stc/cspan.h
index 5b592098..dd6cb1c0 100644
--- a/include/stc/cspan.h
+++ b/include/stc/cspan.h
@@ -265,4 +265,4 @@ STC_DEF intptr_t _cspan_slice(int32_t odim[], int32_t ostri[], int* orank,
#undef i_header
#undef i_implement
#undef i_static
-#undef i_extern
+#undef i_import
diff --git a/include/stc/cstr.h b/include/stc/cstr.h
index ae80dab4..f47889b4 100644
--- a/include/stc/cstr.h
+++ b/include/stc/cstr.h
@@ -405,8 +405,8 @@ STC_INLINE bool cstr_getline(cstr *self, FILE *fp)
#endif // CSTR_H_INCLUDED
-/* -------------------------- EXTERN ------------------------- */
-#if defined(i_extern) && !defined(CSTR_X_INCLUDED)
+/* -------------------------- UTF8 CASE CONVERSION ------------------------- */
+#if defined(i_import) && !defined(CSTR_X_INCLUDED)
#define CSTR_X_INCLUDED
static struct {
@@ -437,11 +437,11 @@ cstr cstr_tocase(csview sv, int k) {
cstr_shrink_to_fit(&out);
return out;
}
-#endif // i_extern
+#endif // i_import
/* -------------------------- IMPLEMENTATION ------------------------- */
#ifndef CSTR_C_INCLUDED
-#if defined i_extern || (defined i_implement && !defined _i_no_undef)
+#if defined i_import || (defined i_implement && !defined _i_no_undef)
#define CSTR_C_INCLUDED
uint64_t cstr_hash(const cstr *self) {
@@ -659,4 +659,4 @@ intptr_t cstr_printf(cstr* self, const char* fmt, ...) {
#undef i_header
#undef i_static
#undef i_implement
-#undef i_extern
+#undef i_import
diff --git a/include/stc/csview.h b/include/stc/csview.h
index d38d5f59..ee217e98 100644
--- a/include/stc/csview.h
+++ b/include/stc/csview.h
@@ -151,7 +151,7 @@ STC_INLINE bool csview_eq(const csview* x, const csview* y)
/* -------------------------- IMPLEMENTATION ------------------------- */
#ifndef CSVIEW_C_INCLUDED
-#if defined i_extern || (defined i_implement && !defined _i_no_undef)
+#if defined i_import || (defined i_implement && !defined _i_no_undef)
#define CSVIEW_C_INCLUDED
csview_iter csview_advance(csview_iter it, intptr_t pos) {
@@ -201,11 +201,10 @@ csview csview_token(csview sv, const char* sep, intptr_t* start) {
*start += tok.size + sep_size;
return tok;
}
-
#endif
#endif
#undef i_opt
#undef i_header
#undef i_implement
#undef i_static
-#undef i_extern
+#undef i_import
diff --git a/include/stc/priv/template2.h b/include/stc/priv/template2.h
index d7588ca0..75402150 100644
--- a/include/stc/priv/template2.h
+++ b/include/stc/priv/template2.h
@@ -59,7 +59,7 @@
#undef i_header
#undef i_implement
#undef i_static
-#undef i_extern
+#undef i_import
#undef i_allocator
#undef i_malloc
diff --git a/include/stc/utf8.h b/include/stc/utf8.h
index 338f0db9..e853263b 100644
--- a/include/stc/utf8.h
+++ b/include/stc/utf8.h
@@ -115,14 +115,14 @@ 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 || (defined i_implement && !defined _i_no_undef)
+#if defined i_import || (defined i_implement && !defined _i_no_undef)
# include "../../src/utf8code.c"
#endif
#ifndef _i_no_undef
#undef i_static
#undef i_header
#undef i_implement
-#undef i_extern
+#undef i_import
#undef i_opt
#endif
#undef _i_no_undef
diff --git a/misc/examples/forfilter.c b/misc/examples/forfilter.c
index f9505aa9..94a84065 100644
--- a/misc/examples/forfilter.c
+++ b/misc/examples/forfilter.c
@@ -1,5 +1,5 @@
#include <stdio.h>
-#define i_extern
+#define i_import
#include <stc/cstr.h>
#define i_implement
#include <stc/csview.h>
diff --git a/misc/examples/regex1.c b/misc/examples/regex1.c
index 4a56b8ac..d8032358 100644
--- a/misc/examples/regex1.c
+++ b/misc/examples/regex1.c
@@ -1,4 +1,4 @@
-#define i_extern
+#define i_import
#include <stc/cregex.h>
int main(int argc, char* argv[])
diff --git a/misc/examples/regex2.c b/misc/examples/regex2.c
index 3133f7c2..5718a1d8 100644
--- a/misc/examples/regex2.c
+++ b/misc/examples/regex2.c
@@ -1,4 +1,4 @@
-#define i_extern
+#define i_import
#include <stc/cregex.h>
int main()
diff --git a/misc/examples/regex_match.c b/misc/examples/regex_match.c
index b4932015..ebda366f 100644
--- a/misc/examples/regex_match.c
+++ b/misc/examples/regex_match.c
@@ -1,4 +1,4 @@
-#define i_extern
+#define i_import
#include <stc/cregex.h>
#define i_implement
#include <stc/csview.h>
diff --git a/misc/examples/regex_replace.c b/misc/examples/regex_replace.c
index cad195d5..2c7794af 100644
--- a/misc/examples/regex_replace.c
+++ b/misc/examples/regex_replace.c
@@ -1,4 +1,4 @@
-#define i_extern
+#define i_import
#include <stc/cregex.h>
#include <stc/csview.h>
#include <stc/algo/raii.h>
diff --git a/misc/examples/splitstr.c b/misc/examples/splitstr.c
index 658c46a1..32b5f17f 100644
--- a/misc/examples/splitstr.c
+++ b/misc/examples/splitstr.c
@@ -1,5 +1,5 @@
#include <stdio.h>
-#define i_extern // cstr + utf8 functions
+#define i_import // cstr + utf8 functions
#include <stc/cregex.h>
#define i_implement
#include <stc/csview.h>
diff --git a/misc/tests/cregex_test.c b/misc/tests/cregex_test.c
index 301ecf4f..3ddcc608 100644
--- a/misc/tests/cregex_test.c
+++ b/misc/tests/cregex_test.c
@@ -1,4 +1,4 @@
-#define i_extern
+#define i_import
#include <stc/cregex.h>
#include <stc/csview.h>
#include <stc/algo/raii.h>
diff --git a/src/cregex.c b/src/cregex.c
index 62a64b11..1af719b4 100644
--- a/src/cregex.c
+++ b/src/cregex.c
@@ -27,7 +27,7 @@ THE SOFTWARE.
#define CREGEX_C_INCLUDED
#include <setjmp.h>
-#ifdef i_extern
+#ifdef i_import
# define _i_extern
#endif
#ifndef CREGEX_H_INCLUDED
diff --git a/src/libstc.c b/src/libstc.c
index 99611e05..afc19a08 100644
--- a/src/libstc.c
+++ b/src/libstc.c
@@ -1,6 +1,6 @@
#include <stddef.h>
#if 1
-#define i_extern
+#define i_import
#include "../include/stc/utf8.h"
#define i_implement
#include "../include/stc/cstr.h"
@@ -9,7 +9,7 @@
#define i_implement
#include "../include/stc/csview.h"
#else
-#define i_extern
+#define i_import
#include "../include/stc/cregex.h"
#define i_implement
#include "../include/stc/csview.h"