summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-03-10 18:36:28 +0100
committerTyge Løvset <[email protected]>2023-03-10 18:36:28 +0100
commit1ac8bb4ff664baa838b44ed6bf62225766f000c5 (patch)
tree464e2024d4db8f43c4e98067cd3d50ebcc02ac83 /include/stc
parentfde6d44c76efdfc8752705122204c38281a844dd (diff)
downloadSTC-modified-1ac8bb4ff664baa838b44ed6bf62225766f000c5.tar.gz
STC-modified-1ac8bb4ff664baa838b44ed6bf62225766f000c5.zip
Added short names by default to c11/fmt.h print, println and printd.
c_forwhile() now takes container not start iter: may be removed! Cleanup in filter.h
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/algo/filter.h16
-rw-r--r--include/stc/ccommon.h4
2 files changed, 9 insertions, 11 deletions
diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h
index 4c257fd3..a5e11b64 100644
--- a/include/stc/algo/filter.h
+++ b/include/stc/algo/filter.h
@@ -49,25 +49,23 @@ int main()
#include <stc/ccommon.h>
-#ifndef c_NFILTERS
-#define c_NFILTERS 32
-#endif
-
-#define c_flt_take(i, n) _flt_take(&(i).b, n)
#define c_flt_skip(i, n) (c_flt_count(i) > (n))
#define c_flt_skipwhile(i, pred) ((i).b.s2[(i).b.s2top++] |= !(pred))
+#define c_flt_take(i, n) _flt_take(&(i).b, n)
#define c_flt_takewhile(i, pred) _flt_takewhile(&(i).b, pred)
-#define c_flt_transform(i, expr) (*((i).ref = &(i).val) = expr, true)
-#define c_flt_last(i) (i).b.s1[(i).b.s1top-1]
#define c_flt_count(i) ++(i).b.s1[(i).b.s1top++]
+#define c_flt_last(i) (i).b.s1[(i).b.s1top - 1]
#define c_forfilter(i, C, cnt, filter) \
- for (struct {struct _flt_base b; C##_iter it; C##_value *ref, val;} \
+ for (struct {struct _flt_base b; C##_iter it; C##_value *ref;} \
i = {.it=C##_begin(&cnt), .ref=i.it.ref} ; !i.b.done & (i.it.ref != NULL) ; \
C##_next(&i.it), i.ref = i.it.ref, i.b.s1top=0, i.b.s2top=0) \
if (!(filter)) ; else
-// -----
+// ------------------------ private -------------------------
+#ifndef c_NFILTERS
+#define c_NFILTERS 32
+#endif
struct _flt_base {
uint32_t s1[c_NFILTERS];
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index d163b4ab..de230910 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -178,9 +178,9 @@ STC_INLINE char* cstrnstrn(const char *str, const char *needle,
for (C##_iter it = start, *_endref = (C##_iter*)(finish).ref \
; it.ref != (C##_value*)_endref; C##_next(&it))
-#define c_forwhile(i, C, start, cond) \
+#define c_forwhile(i, C, cnt, cond) \
for (struct {C##_iter it; C##_value *ref; intptr_t index;} \
- i = {.it=start, .ref=i.it.ref}; i.it.ref && (cond) \
+ i = {.it=C##_begin(&cnt), .ref=i.it.ref}; i.it.ref && (cond) \
; C##_next(&i.it), i.ref = i.it.ref, ++i.index)
#define c_forpair(key, val, C, cnt) /* structured binding */ \