summaryrefslogtreecommitdiffhomepage
path: root/include/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-09-26 19:28:48 +0200
committerTyge Løvset <[email protected]>2022-09-26 19:28:48 +0200
commit2c31b421b6c867ab956a843dace0d95769a97667 (patch)
tree07c9fe0b12c78117e6b59a58c70de3d6e7bd72a9 /include/stc
parent2e3db1c709e88d68cece8c46566ca6b8481b7c07 (diff)
downloadSTC-modified-2c31b421b6c867ab956a843dace0d95769a97667.tar.gz
STC-modified-2c31b421b6c867ab956a843dace0d95769a97667.zip
Added .count to c_forfilter() algorithm. Updated prime.c example, and added forloops.c example.
Diffstat (limited to 'include/stc')
-rw-r--r--include/stc/ccommon.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 2edab5bc..1961833b 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -176,11 +176,11 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle,
#define c_forfilter5(it, C, cnt, filter, whilepred) \
c_forfilter_s(it, C, C##_begin(&cnt), filter) if (!(whilepred)) break; else
#define c_forfilter_s(it, C, start, filter) \
- c_foreach_s(it, C, start) if (!(filter)) ; else
+ c_foreach_s(it, C, start) if (!((filter) && ++it.count)) ; else
#define c_foreach_s(i, C, start) \
for (struct {C##_iter it; C##_value *ref; \
- uint32_t s1[c_FLT_STACK+1], index; \
+ uint32_t s1[c_FLT_STACK], index, count; \
uint8_t s2[c_FLT_STACK], s1top, s2top;} \
i = {.it=start, .ref=i.it.ref}; i.it.ref \
; C##_next(&i.it), i.ref = i.it.ref, ++i.index, i.s1top=0, i.s2top=0)